"use strict";(self.webpackChunk_aidoop_aidoop_r=self.webpackChunk_aidoop_aidoop_r||[]).push([[2139],{22139:(t,r,i)=>{i.r(r);i(77198),i(81748),i(69377),i(16441);var o=i(50493),e=i(94430),a=i(56765),s=i(98491),n=i(71277);let d=class extends e.oi{render(){return e.dy`
      <ul>
        <li ?active=${!this.groupId}>
          <a href=${this.targetPage||""}><mwc-icon>dashboard</mwc-icon></a>
        </li>

        <li ?active=${"favor"===this.groupId}>
          <a href="${this.targetPage}/favor"><mwc-icon>star</mwc-icon></a>
        </li>

        ${(this.groups||[]).map((t=>e.dy`
            <li ?active=${this.groupId===t.id} @long-press=${r=>this.infoGroup(t.id)}>
              <a href=${`${this.targetPage}/${t.id}`}>${t.name}</a>
            </li>
          `))}

        <li padding></li>

        <li add>
          <mwc-icon @click=${t=>this.infoGroup()}>add</mwc-icon>
        </li>
      </ul>
    `}infoGroup(t){this.dispatchEvent(new CustomEvent("info-group",{detail:t}))}onWheelEvent(t){var r=Math.max(-1,Math.min(1,t.wheelDelta||-t.detail));this.scrollLeft-=40*r,t.preventDefault()}updated(t){if(t.has("groups")&&this.__sb&&this.__sb.updateMetrics(),t.has("groupId")){var r=this.renderRoot.querySelector("li[active]");r&&r.scrollIntoView()}}firstUpdated(){var t=this.renderRoot.querySelector("ul");(0,n.J1)(t),t.addEventListener("mousewheel",this.onWheelEvent.bind(this),!1),this.__sb=new s.Z({viewport:this,content:t,mode:"x",onUpdate:t=>{this.scrollLeft=t.position.x}})}};d.styles=[e.iv`
      :host {
        background-color: var(--group-bar-background-color);

        overflow-x: hidden;
      }

      ul {
        display: flex;
        list-style: none;
        margin: 0;
        padding: 0;
        white-space: nowrap;
      }

      li {
        display: inline-block;
        padding: 0px 3px;

        border-bottom: var(--group-bar-line);
      }

      li[active] {
        border-color: var(--group-bar-active-line-color);
      }

      li a {
        display: block;
        padding: 5px 4px 1px 4px;
        text-decoration: none;
        font: var(--group-bar-textbutton);
        color: rgba(255, 255, 255, 0.8);
      }

      li[active] a {
        font: var(--group-bar-textbutton-active);
        color: rgba(255, 255, 255, 1);
      }

      li[padding] {
        flex: 1;
      }

      li[add] {
        padding: 5px 4px 1px 4px;
      }

      li[add] * {
        color: rgba(255, 255, 255, 0.5);
      }

      mwc-icon {
        vertical-align: middle;
      }
    `],(0,o.gn)([(0,a.Cb)({type:Array}),(0,o.w6)("design:type",Array)],d.prototype,"groups",void 0),(0,o.gn)([(0,a.Cb)({type:String}),(0,o.w6)("design:type",String)],d.prototype,"groupId",void 0),(0,o.gn)([(0,a.Cb)({type:String}),(0,o.w6)("design:type",String)],d.prototype,"targetPage",void 0),d=(0,o.gn)([(0,a.Mo)("group-bar")],d);var l=i(16682),p=i(28120),h=i(27805),u=i(53421),g=i(37077),c=i(93074),f=i(77675),y=i(15633),b=i(92535),m=i(13756),v=i(60977);class w extends((0,u.NC)(u.z2)((0,p.$)(f.h)((0,b.Z)(f.B4)))){static get styles(){return[y.Ix,e.iv`
        :host {
          display: flex;
          flex-direction: column;
          position: relative;

          overflow: hidden;
        }

        board-tile-list {
          flex: 1;
          overflow-y: auto;
        }

        #create {
          position: absolute;
          bottom: 15px;
          right: 16px;
        }
      `]}static get properties(){return{groupId:String,groups:Array,boards:Array,favorites:Array,boardPermissions:Array,_page:Number,_total:Number}}get context(){var t=this.groups&&this.groups.find((t=>t.id===this.groupId));return{title:{icon:"dashboard",text:t?t.name:"Board List"},board_topmenu:!0}}constructor(){super(),this._page=1,this._total=0,this._infiniteScrollOptions.limit=50}render(){var t;return e.dy`
      <group-bar
        .groups=${this.groups}
        .groupId=${this.groupId}
        targetPage="board-list"
        @info-group=${t=>this.onInfoGroup(t.detail)}
      ></group-bar>

      <board-tile-list
        id="list"
        .boards=${this.boards}
        .favorites=${this.favorites}
        .groups=${this.groups}
        .group=${this.groupId}
        ?creatable=${null===(t=this.boardPermissions)||void 0===t?void 0:t.includes("Modeller")}
        @info-board=${t=>this.onInfoBoard(t.detail)}
        @scroll=${t=>{this.onScroll(t)}}
        @create-board=${t=>this.onCreateBoard(t.detail)}
        @refresh-favorites=${t=>this.refreshFavorites()}
      ></board-tile-list>
    `}get scrollTargetEl(){return this.shadowRoot.querySelector("board-tile-list")}async refresh(){this.groups=(await(0,v.Ys)()).groups.items,this.groups&&await this.refreshBoards()}async getBoards({page:t=1,limit:r=this._infiniteScrollOptions.limit}={}){if(this.groupId&&"favor"==this.groupId)return await this.getFavoriteBoards({page:t,limit:r});var i={filters:this.groupId?[{name:"groupId",operator:"eq",value:this.groupId}]:[],sortings:[{name:"name",desc:!1}],pagination:{page:t,limit:r}};return(await(0,v.tn)(i)).boards}async getFavoriteBoards({page:t=1,limit:r=this._infiniteScrollOptions.limit}={}){var i={pagination:{page:t,limit:r}};return(await(0,v.Ol)(i)).favoriteBoards}async refreshBoards(){if(this.groups){var{items:t,total:r}=await this.getBoards();this.boards=t,this._page=1,this._total=r,this.updateContext();var i=this.shadowRoot.querySelector("board-tile-list");i.style.transition="",i.style.transform="translate3d(0, 0, 0)"}else await this.refresh()}async appendBoards(){if(this.groups){var{items:t,total:r}=await this.getBoards({page:this._page+1});this.boards=[...this.boards,...t],this._page=this._page+1,this._total=r}else await this.refresh()}async scrollAction(){return this.appendBoards()}async pageInitialized(){this.refresh()}async pageUpdated(t,r){this.active&&(this.page=r.page,this.groupId=r.resourceId,await this.updateComplete,this.refreshBoards())}stateChanged(t){this.favorites=t.favorite.favorites,this.boardPermissions=t.permissions.boardPermissions}firstUpdated(){var t=this.shadowRoot.querySelector("board-tile-list");(0,c.A)({container:this.shadowRoot,scrollable:t,refresh:()=>this.refresh()}),(0,n.aq)({container:t,animates:{dragging:async(r,i)=>{var o=[{id:""},{id:"favor"},...this.groups],e=o.findIndex((t=>t.id==this.groupId));if(r>0&&e<=0||r<0&&e>=o.length-1)return!1;t.style.transform=`translate3d(${r}px, 0, 0)`},aborting:async r=>{t.style.transition="transform 0.3s",t.style.transform="translate3d(0, 0, 0)",setTimeout((()=>{t.style.transition=""}))},swiping:async(r,i)=>{var o=[{id:""},{id:"favor"},...this.groups],e=o.findIndex((t=>t.id==this.groupId));r>0&&e<=0||r<0&&e>=o.length-1?(t.style.transition="",t.style.transform="translate3d(0, 0, 0)"):(t.style.transition="transform 0.3s",t.style.transform=`translate3d(${r<0?"-100%":"100%"}, 0, 0)`,(0,f.c4)(`${this.page}/${o[e+(r<0?1:-1)].id}`))}}})}async onInfoBoard(t){var r;(0,g.IK)("viewpart-info",{template:e.dy`
        <board-info
          .board=${t}
          .groupId=${this.groupId}
          ?enable-modeller=${null===(r=this.boardPermissions)||void 0===r?void 0:r.includes("Modeller")}
          @clone-board=${t=>this.onCloneBoard(t.detail)}
          @release-board=${t=>this.onReleaseBoard(t.detail)}
          @revert-board-version=${t=>this.onRevertBoardVersion(t.detail)}
          @update-board=${t=>this.onUpdateBoard(t.detail)}
          @delete-board=${t=>this.onDeleteBoard(t.detail)}
          @join-playgroup=${t=>this.onJoinPlayGroup(t.detail)}
          @leave-playgroup=${t=>this.onLeavePlayGroup(t.detail)}
        ></board-info>
      `})}async onInfoGroup(t){(0,g.IK)("viewpart-info",{template:e.dy`
        <group-info
          .groupId=${t}
          @update-group=${t=>this.onUpdateGroup(t.detail)}
          @delete-group=${t=>this.onDeleteGroup(t.detail)}
          @create-group=${t=>this.onCreateGroup(t.detail)}
          @import-boards=${t=>this.onImportBoards(t.detail)}
        ></group-info>
      `})}async onCreateGroup(t){try{await(0,v.sS)(t)&&this._notify("info",u.z2.t("text.group created",{group:t.name}))}catch(t){this._notify("error",t,t)}this.refresh()}async onUpdateGroup(t){try{await(0,v.mD)(t)&&this._notify("info",u.z2.t("text.group updated",{group:t.name}))}catch(t){this._notify("error",t,t)}this.refresh()}async onDeleteGroup(t){try{await(0,v.iE)(t.id)&&this._notify("info",u.z2.t("text.group deleted",{group:t.name}))}catch(t){this._notify("error",t,t)}this.refresh()}async onImportBoards({group:t,files:r,overwrite:i}){try{await(0,v.Dr)({groupId:t.id,files:r,overwrite:i})&&this._notify("info",u.z2.t("text.boards imported",{count:r.length,group:t.name}))}catch(t){this._notify("error",t,t)}this.refresh()}async onCreateBoard(t){try{t.model||(t.model={width:800,height:600});await(0,v.aX)(t)&&this._notify("info",u.z2.t("text.board created",{board:t.name}))}catch(t){this._notify("error",t,t)}this.refreshBoards()}async onCloneBoard({id:t,name:r,description:i,targetSubdomain:o,targetGroupId:e}){try{await(0,v.GM)({id:t,name:r,description:i,targetSubdomain:o,targetGroupId:e})&&this._notify("info",u.z2.t("text.board cloned",{board:r}))}catch(t){this._notify("error",t,t)}this.refreshBoards()}async onReleaseBoard(t){try{await(0,v.RE)(t)&&this._notify("info",u.z2.t("text.board released",{board:t.name}))}catch(t){this._notify("error",t,t)}this.refreshBoards()}async onRevertBoardVersion({id:t,version:r}){try{const i=await(0,v.Vs)(t,r);i&&this._notify("info",u.z2.t("text.board reverted",{board:i.name,version:r}))}catch(t){this._notify("error",t,t)}this.refreshBoards()}async onUpdateBoard(t){try{await(0,v.wN)(t)&&this._notify("info",u.z2.t("text.board updated",{board:t.name}))}catch(t){this._notify("error",t,t)}this.refreshBoards()}async onDeleteBoard(t){try{await(0,v.L1)(t.id)&&this._notify("info",u.z2.t("text.board deleted",{board:t.name}))}catch(t){this._notify("error",t,t)}this.refreshBoards()}async onJoinPlayGroup({board:t,playGroup:r}){try{const{data:i}=await h.Lp.mutate({mutation:l.ZP`
          mutation JoinPlayGroup($id: String!, $boardIds: [String!]!) {
            joinPlayGroup(id: $id, boardIds: $boardIds) {
              id
            }
          }
        `,variables:{id:r.id,boardIds:[t.id]}});i&&this._notify("info",u.z2.t("text.joined into play-group",{board:t.name,playGroup:r.name}))}catch(t){this._notify("error",t,t)}}async onLeavePlayGroup({board:t,playGroup:r}){try{const{data:i}=await h.Lp.mutate({mutation:l.ZP`
          mutation ($id: String!, $boardIds: [String!]!) {
            leavePlayGroup(id: $id, boardIds: $boardIds) {
              id
            }
          }
        `,variables:{id:r.id,boardIds:[t.id]}});i&&this._notify("info",u.z2.t("text.leaved from play-group",{board:t.name,playGroup:r.name}))}catch(t){this._notify("error",t,t)}}async refreshFavorites(){const{data:t}=await h.Lp.query({query:l.ZP`
        query {
          myFavorites {
            id
            routing
          }
        }
      `});t&&f.h.dispatch({type:m.U,favorites:t.myFavorites.map((t=>t.routing))})}_notify(t,r,i){document.dispatchEvent(new CustomEvent("notify",{detail:{level:t,message:r,ex:i}}))}}window.customElements.define("board-list-page",w)}}]);