1import{b as je}from"./chunk-Q4HPZ5V4.js";import{$ as j,Aa as De,B as Te,Ba as M,Hb as Ne,Pa as Me,Ra as Oe,Xa as Ae,Ya as Fe,Za as ke,ba as we,ca as K,fb as Ve,ka as ye,u as Ie,ua as Le,va as Re,wa as Q,x as xe,xb as $e,yb as Be,z as Ee}from"./chunk-5HVYPHXR.js";import{A as ve,z as ge}from"./chunk-KYHKX4YL.js";import{d as D}from"./chunk-VTFRECQP.js";import"./chunk-I6MWARA7.js";import"./chunk-72UM2OEF.js";import"./chunk-XYMFHARZ.js";import{d as Se,e as be}from"./chunk-HFX25ZVC.js";import{T as _e,V as Ce,Z as J,e as de,k as ue,p as fe,x as he}from"./chunk-ZALSVSJ7.js";import{$b as c,Bb as T,Bc as H,Ea as b,Fa as I,Ic as z,Jc as u,Kb as se,Kc as N,Lb as $,Lc as _,Mc as le,Nc as pe,O as te,Oa as re,Pa as oe,Pb as g,Q as L,S as F,Vc as ce,W as U,Yc as q,bd as l,cd as d,dd as G,ea as W,fd as Z,gc as B,ia as ie,jc as ae,kc as me,lc as s,mc as a,nc as v,oa as ne,oc as w,pa as k,pc as y,qb as Y,rc as R,ta as V,vb as r,w as E,wc as x,x as ee,xc as h}from"./chunk-YSIISRS7.js";import{a as C,b as S}from"./chunk-PHUH23IY.js";var He={hasMore:!1,isDeleting:!1,isLoading:!1,items:[],loaded:!1,remaining:0,searchTerm:"",totalCount:0},P=(()=>{class t extends we{constructor(e,i,o){super(He),this.api=e,this.customersService=i,this.errorHandler=o,this.setIsDeleting=this.updater((n,m)=>S(C({},n),{isDeleting:m})),this.setIsLoading=this.updater((n,m)=>S(C({},n),{isLoading:m})),this.loadCustomers=this.effect(n=>n.pipe(W(m=>(this.setIsLoading(!0),this.api.listCustomers(m?.offset,m?.searchTerm,m?.view_as).pipe(K(f=>{let O=f.items.map(A=>({value:A})),We=f.totalItems-O.length;this.setState(A=>((m?.append??!1)===!0&&(O=[...A.items,...O]),S(C({},A),{hasMore:f.hasMore,totalCount:f.totalItems,remaining:We,items:O,loaded:!0})))},f=>this.errorHandler.handleError(f)),U(()=>this.setIsLoading(!1))))))),this.setSearchTerm=this.updater((n,m)=>S(C({},n),{searchTerm:m})),this.setViewAs=this.updater((n,m)=>S(C({},n),{viewAs:m})),this.subscriptions=new D,this.vm$=this.select(n=>C({},n)),this.delete=this.effect(n=>n.pipe(ie(()=>this.setIsDeleting(!0)),W(m=>this.api.delete(m).pipe(K(()=>{},f=>this.errorHandler.handleError(f)),U(()=>this.setIsDeleting(!1)))))),this.subscriptions.add(this.customersService.customerCreated.subscribe(n=>this.customerCreated(n))),this.subscriptions.add(this.customersService.customerSaved.subscribe(n=>this.customerChanged(n))),this.subscriptions.add(this.customersService.customerDeleted.subscribe(n=>this.customerDeleted(n)))}customerCreated(e){this.setState(i=>{let o={value:e};return S(C({},i),{items:[o,...i.items]})})}customerChanged(e){this.setState(i=>(i.items.filter(o=>o.value.id===e.id).map(o=>(o.value=e,o)),C({},i)))}customerDeleted(e){this.setState(i=>S(C({},i),{items:i.items.filter(o=>o.value.id!==e.id)}))}static{this.\u0275fac=function(i){return new(i||t)(V(Q),V(Re),V(oe))}}static{this.\u0275prov=ne({token:t,factory:t.\u0275fac})}}return t})();var qe=t=>({count:t}),Ge=t=>({remaining:t}),Ze=(t,p)=>p.value.id;function Je(t,p){if(t&1){let e=R();s(0,"app-page-toolbar",4),l(1,"translate"),s(2,"app-partner-selector",28),x("partner-changed",function(o){b(e);let n=h(2);return I(n.setViewAs(o))}),a()()}t&2&&c("title",d(1,1,"WORDS.ADMINISTRATION"))}function Ke(t,p){t&1&&(s(0,"th"),u(1),l(2,"translate"),a()),t&2&&(r(),_(" ",d(2,1,"CUSTOMERS.FIELDS.SALESMAN.LABEL")," "))}function Qe(t,p){if(t&1&&v(0,"app-customer-editor",41),t&2){let e=p.$implicit,i=h().$implicit,o=h().ngIf;c("customer-id",i.value.id)("modal-ref",e)("viewAs",o.viewAs==null?null:o.viewAs.id)}}function Xe(t,p){if(t&1&&(w(0),s(1,"a",42),u(2),a(),y()),t&2){let e=p.ngIf;r(),H("href","mailto:",e,"",Y),r(),N(e)}}function et(t,p){if(t&1&&(w(0),s(1,"span"),u(2),a(),y()),t&2){let e=h().$implicit;r(2),le("",e.value.principal.first_name," ",e.value.principal.last_name,"")}}function tt(t,p){if(t&1&&(w(0),s(1,"a",42),u(2),a(),y()),t&2){let e=p.ngIf;r(),H("href","mailto:",e,"",Y),r(),N(e)}}function it(t,p){t&1&&u(0),t&2&&_(" ",p.name," ")}function nt(t,p){if(t&1&&(s(0,"td"),g(1,it,1,1),a()),t&2){let e,i=h().$implicit;r(),B((e=i.value.salesman)?1:-1,e)}}function rt(t,p){if(t&1){let e=R();s(0,"app-delete-confirmation",43),x("confirmed",function(){b(e);let o=h().$implicit,n=h(2);return I(n.delete(o.value))}),a()}}function ot(t,p){if(t&1){let e=R();g(0,Qe,1,3,"ng-template",null,0,Z),s(2,"tr",29)(3,"td"),u(4),a(),s(5,"td",30),u(6),a(),s(7,"td")(8,"address",31),u(9),v(10,"br"),u(11),a()(),s(12,"td")(13,"div",32)(14,"span"),u(15),a(),g(16,Xe,3,3,"ng-container",2),a()(),s(17,"td")(18,"div",32),g(19,et,3,2,"ng-container",2)(20,tt,3,3,"ng-container",2),a()(),g(21,nt,2,1,"td"),l(22,"allows"),s(23,"td"),g(24,rt,1,0,"ng-template",null,1,Z),s(26,"div",33)(27,"div",34)(28,"button",35),l(29,"translate"),x("click",function(){let o=b(e).$implicit,n=h(2);return I(n.searchDocuments(o.value))}),s(30,"i",36),v(31,"span",8)(32,"span",9)(33,"span",10),a()(),s(34,"button",35),l(35,"translate"),x("click",function(){b(e);let o=z(1),n=h(2);return I(n.openDialog(o,{size:"lg"}))}),s(36,"i",37),v(37,"i",8)(38,"i",9),a()(),s(39,"button",38),l(40,"translate"),s(41,"i",39),v(42,"i",8)(43,"i",9)(44,"i",10)(45,"i",13)(46,"i",40),a()()()()()()}if(t&2){let e=p.$implicit,i=z(25);r(4),_(" ",e.value.yf_company_id," "),r(2),_(" ",e.value.name," "),r(3),_(" ",e.value.address.street,""),r(2),pe(" ",e.value.address.country,"-",e.value.address.postcode," ",e.value.address.city," "),r(4),N(e.value.contact.name),r(),c("ngIf",e.value.contact.email),r(3),c("ngIf",e.value.principal.first_name||e.value.principal.last_name),r(),c("ngIf",e.value.principal.email),r(),B(d(22,16,"betatester")?21:-1),r(7),c("ngbTooltip",d(29,18,"CUSTOMERS.TOOLTIPS.SEARCH_DOCUMENTS")),r(6),c("ngbTooltip",d(35,20,"WORDS.EDIT")),r(5),c("container","body")("ngbTooltip",d(40,22,"WORDS.DELETE"))("ngbPopover",i)}}function st(t,p){t&1&&(w(0),s(1,"tr")(2,"td",44),u(3),l(4,"translate"),a()(),y()),t&2&&(r(3),_(" ",d(4,1,"WORDS.NO_RECORDS_FOUND")," "))}function at(t,p){if(t&1){let e=R();s(0,"div",45)(1,"button",46),x("click",function(){b(e);let o=h(2);return I(o.loadMore())}),u(2),l(3,"translate"),a()()}if(t&2){let e=h().ngIf;r(),c("status",e.isLoading),r(),_(" ",G(3,2,"WORDS.LOAD_MORE_REMAINING",q(5,Ge,e.remaining))," ")}}function mt(t,p){t&1&&(w(0),s(1,"div",47),v(2,"app-loader-intermediate",48),l(3,"translate"),a(),y()),t&2&&(r(2),c("message",d(3,1,"WORDS.LOADING")))}function lt(t,p){if(t&1){let e=R();w(0),s(1,"app-page-scaffold",3),l(2,"translate"),v(3,"app-breadcrumb",4),l(4,"translate"),g(5,Je,3,3,"app-page-toolbar",5),l(6,"allows"),s(7,"app-page-toolbar",4),l(8,"translate"),s(9,"button",6),x("click",function(){b(e);let o=h();return I(o.addCustomer())}),s(10,"i",7),v(11,"i",8)(12,"i",9)(13,"i",10),a()(),s(14,"button",11),x("click",function(){b(e);let o=h();return I(o.reload())}),s(15,"i",12),v(16,"i",8)(17,"i",9)(18,"i",10)(19,"i",13),a()()(),s(20,"div",14)(21,"div",15)(22,"div",16)(23,"span",17),u(24),l(25,"translate"),a(),s(26,"span",18),u(27),l(28,"translate"),a()(),s(29,"div",19)(30,"app-search-input",20),x("valueChange",function(o){b(e);let n=h();return I(n.setSearchTerm(o))}),a()()(),s(31,"div",21)(32,"div",22)(33,"div",23)(34,"table",24)(35,"thead")(36,"tr",25)(37,"th"),u(38),l(39,"translate"),a(),s(40,"th"),u(41),l(42,"translate"),a(),s(43,"th"),u(44),l(45,"translate"),a(),s(46,"th"),u(47),l(48,"translate"),a(),s(49,"th"),u(50),l(51,"translate"),a(),g(52,Ke,3,3,"th"),l(53,"allows"),v(54,"th"),a()(),s(55,"tbody",26),ae(56,ot,47,24,null,null,Ze),g(58,st,5,3,"ng-container",2),a()()(),g(59,at,4,7,"div",27)(60,mt,4,3,"ng-container",2),a()()()(),y()}if(t&2){let e=p.ngIf;r(),c("is-loading",e.isLoading)("page-title",d(2,18,"CUSTOMERS.PAGE.TITLE")),r(2),c("title",d(4,20,"WORDS.OVERVIEW")),r(2),c("ngIf",d(6,22,"customers.view_as")),r(2),c("title",d(8,24,"WORDS.ACTIONS")),r(7),c("disabled",e.isLoading),r(10),_(" ",d(25,26,"CUSTOMERS.OVERVIEW.TITLE")," "),r(3),_(" ",G(28,28,"CUSTOMERS.OVERVIEW.RECORD_INFORMATION",q(43,qe,e.totalCount))," "),r(3),c("value",e.searchTerm),r(8),_(" ",d(39,31,"CUSTOMERS.FIELDS.COMPANY_ID")," "),r(3),_(" ",d(42,33,"CUSTOMERS.FIELDS.NAME")," "),r(3),_(" ",d(45,35,"CUSTOMERS.FIELDS.ADDRESS")," "),r(3),_(" ",d(48,37,"CUSTOMERS.FIELDS.CONTACT")," "),r(3),_(" ",d(51,39,"CUSTOMERS.FIELDS.PRINCIPAL")," "),r(2),B(d(53,41,"betatester")?52:-1),r(4),me(e.items),r(2),c("ngIf",e.loaded&&e.items.length===0),r(),c("ngIf",e.hasMore),r(),c("ngIf",e.isLoading&&!e.loaded)}}var Pe=(()=>{class t{constructor(e,i,o,n,m,f){this.store=e,this.router=i,this.route=o,this.modalService=n,this.location=m,this.ngZone=f,this.setSearchTerm=this.store.setSearchTerm,this.subscriptions=new D,this.vm$=this.store.vm$}delete(e){this.store.delete(e)}loadMore(){let e=this.vm$.pipe(L(1),E(i=>({searchTerm:i.searchTerm,view_as:i.viewAs?.id,offset:i.items.length,append:!0})));this.store.loadCustomers(e)}ngOnDestroy(){this.subscriptions.clear()}ngOnInit(){let e=this.vm$.pipe(te(200),E(m=>m.searchTerm),F()),i=this.vm$.pipe(E(m=>m.viewAs?.id),F()),o=ee([e,i]).pipe(E(([m,f])=>({searchTerm:m,view_as:f})));this.store.loadCustomers(o);let n=window.history.state&&window.history.state.customersListState?window.history.state.customersListState:void 0;if(n)if(n.searchTerm!==void 0&&this.setSearchTerm(n.searchTerm),this.targetItemsLength=typeof n.itemsLength=="number"?n.itemsLength:void 0,this.targetScrollY=typeof n.scrollY=="number"?n.scrollY:void 0,this.targetItemsLength&&this.targetItemsLength>0){let m=this.vm$.pipe(E(f=>f.items.length),F()).subscribe(f=>{this.targetItemsLength&&f<this.targetItemsLength?this.loadMore():this.targetItemsLength&&f>=this.targetItemsLength&&(typeof this.targetScrollY=="number"?this.scrollToWhenReady(this.targetScrollY,()=>{this.targetItemsLength=void 0,this.targetScrollY=void 0,m.unsubscribe()}):(this.targetItemsLength=void 0,this.targetScrollY=void 0,m.unsubscribe()))})}else typeof this.targetScrollY=="number"&&this.scrollToWhenReady(this.targetScrollY)}openDialog(e,i){return this.modalService.open(e,i)}openCustomerEditor(){return this.modalService.open(M,{size:"xl",backdrop:"static"})}addCustomer(){let e=this.openCustomerEditor();e.componentInstance instanceof M&&(e.componentInstance.modalRef=e,this.vm$.pipe(L(1)).subscribe(o=>{e.componentInstance.viewAs=o.viewAs?.id}).unsubscribe(),e.componentInstance.setCustomer(new Le({use_address_for_billing:!0})))}reload(){let e=this.vm$.pipe(L(1),E(i=>({searchTerm:i.searchTerm,view_as:i.viewAs?.id,offset:0})));this.store.loadCustomers(e)}searchDocuments(e){this.saveCurrentListState(),this.router.navigate(["..","documents"],{relativeTo:this.route,queryParams:{c:e.id}})}saveCurrentListState(){this.vm$.pipe(L(1)).subscribe(i=>{let o={searchTerm:i.searchTerm,itemsLength:i.items?.length??0,scrollY:window.scrollY||0},n=C({},window.history.state||{});n.customersListState=o,window.history.replaceState(n,"",this.router.url)}).unsubscribe()}scrollToWhenReady(e,i){let o=()=>{requestAnimationFrame(()=>{window.scrollTo({top:e,behavior:"auto"}),i&&i()})},n=()=>{this.ngZone.onStable.pipe(L(1)).subscribe(()=>o())};document.readyState==="complete"||document.readyState==="interactive"?n():window.addEventListener("load",()=>n(),{once:!0})}setViewAs(e){this.store.setViewAs(e)}static{this.\u0275fac=function(i){return new(i||t)(T(P),T(Ce),T(_e),T(Ie),T(de),T(re))}}static{this.\u0275cmp=se({type:t,selectors:[["app-customer-list"]],standalone:!1,features:[ce([P])],decls:2,vars:3,consts:[["editor",""],["confirmDeletion",""],[4,"ngIf"],[3,"is-loading","page-title"],[3,"title"],[3,"title",4,"ngIf"],["app-header-button","",3,"click"],["app-header-icon","",1,"ki-duotone","ki-add-files"],[1,"path1"],[1,"path2"],[1,"path3"],["app-header-button","",3,"click","disabled"],["app-header-icon","",1,"ki-duotone","ki-update-file"],[1,"path4"],[1,"card"],[1,"card-header","border-0","mt-4"],[1,"card-title","flex-column","align-items-start"],[1,"fw-bolder"],[1,"fw-bold","text-muted","fs-7"],[1,"card-toolbar"],["allow-clear","","icon-type","keen-duotone","size","sm",3,"valueChange","value"],[1,"card-body","py-3"],[1,"d-flex","flex-column","gap-5"],[1,"table-responsive"],[1,"table","table-row-gray-300","align-middle","gs-0","gy-3"],[1,"border-bottom-2","fw-bolder"],[1,""],["class","d-flex justify-content-center mb-10",4,"ngIf"],["size","sm",1,"min-w-100px","min-w-lg-300px",3,"partner-changed"],[1,"position-relative","border-bottom"],[1,"fw-bold"],[1,"m-0"],[1,"d-flex","flex-column"],[1,"d-flex","flex-stack","justify-content-end","gap-1"],[1,"btn-group","btn-group-sm"],[1,"btn","btn-sm","btn-secondary","btn-icon",3,"click","ngbTooltip"],[1,"ki-duotone","ki-filter-search"],[1,"ki-duotone","ki-notepad-edit"],[1,"btn","btn-sm","btn-secondary","btn-active-danger","btn-icon",3,"container","ngbTooltip","ngbPopover"],[1,"ki-duotone","ki-trash"],[1,"path5"],[3,"customer-id","modal-ref","viewAs"],[3,"href"],[3,"confirmed"],["colspan","5",1,"text-center","text-muted","fst-italic"],[1,"d-flex","justify-content-center","mb-10"],["indicator-button","",1,"btn","btn-light",3,"click","
1status"],[1,"py-10"],[3,"message"]],template:function(i,o){i&1&&(g(0,lt,61,45,"ng-container",2),l(1,"async")),i&2&&c("ngIf",d(1,1,o.vm$))},dependencies:[ue,Ae,M,$e,Be,Me,ye,ke,Fe,Ve,Oe,xe,Ee,j,fe,Se,De],encapsulation:2,changeDetection:0})}}return t})();var pt=[{path:"",children:[{path:"",component:Pe}]}],Ue=(()=>{class t{static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275mod=$({type:t})}static{this.\u0275inj=k({imports:[J.forChild(pt),J]})}}return t})();var ci=(()=>{class t{static{this.\u0275fac=function(i){return new(i||t)}}static{this.\u0275mod=$({type:t})}static{this.\u0275inj=k({imports:[he,Ue,be,Ne,je,ge,ve,Te,j]})}}return t})();export{ci as CustomersModule};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.