UNPKG

friday-widgets

Version:

Professional embeddable accounting widgets for vertical SaaS platforms. Layer Financial-inspired design with comprehensive financial reporting capabilities.

1,426 lines 79.3 kB
var FridayChartOfAccountsWidget=function(t){"use strict";function e(t,e,r,a){var i,o=arguments.length,s=o<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,a);else for(var n=t.length-1;n>=0;n--)(i=t[n])&&(s=(o<3?i(s):o>3?i(e,r,s):i(e,r))||s);return o>3&&s&&Object.defineProperty(e,r,s),s}"function"==typeof SuppressedError&&SuppressedError;
/**
     * @license
     * Copyright 2019 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */
const r=globalThis,a=r.ShadowRoot&&(void 0===r.ShadyCSS||r.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),o=new WeakMap;let s=class{constructor(t,e,r){if(this._$cssResult$=!0,r!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(a&&void 0===t){const r=void 0!==e&&1===e.length;r&&(t=o.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),r&&o.set(e,t))}return t}toString(){return this.cssText}};const n=(t,...e)=>{const r=1===t.length?t[0]:e.reduce((e,r,a)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[a+1],t[0]);return new s(r,t,i)},c=a?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const r of t.cssRules)e+=r.cssText;return(t=>new s("string"==typeof t?t:t+"",void 0,i))(e)})(t):t,{is:l,defineProperty:d,getOwnPropertyDescriptor:u,getOwnPropertyNames:h,getOwnPropertySymbols:p,getPrototypeOf:y}=Object,_=globalThis,g=_.trustedTypes,m=g?g.emptyScript:"",b=_.reactiveElementPolyfillSupport,v=(t,e)=>t,f={toAttribute(t,e){switch(e){case Boolean:t=t?m:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let r=t;switch(e){case Boolean:r=null!==t;break;case Number:r=null===t?null:Number(t);break;case Object:case Array:try{r=JSON.parse(t)}catch(t){r=null}}return r}},x=(t,e)=>!l(t,e),w={attribute:!0,type:String,converter:f,reflect:!1,useDefault:!1,hasChanged:x};
/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */Symbol.metadata??=Symbol("metadata"),_.litPropertyMetadata??=new WeakMap;let A=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const r=Symbol(),a=this.getPropertyDescriptor(t,r,e);void 0!==a&&d(this.prototype,t,a)}}static getPropertyDescriptor(t,e,r){const{get:a,set:i}=u(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:a,set(e){const o=a?.call(this);i?.call(this,e),this.requestUpdate(t,o,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(v("elementProperties")))return;const t=y(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(v("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(v("properties"))){const t=this.properties,e=[...h(t),...p(t)];for(const r of e)this.createProperty(r,t[r])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,r]of e)this.elementProperties.set(t,r)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const r=this._$Eu(t,e);void 0!==r&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const r=new Set(t.flat(1/0).reverse());for(const t of r)e.unshift(c(t))}else void 0!==t&&e.push(c(t));return e}static _$Eu(t,e){const r=e.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const r of e.keys())this.hasOwnProperty(r)&&(t.set(r,this[r]),delete this[r]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(a)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const a of e){const e=document.createElement("style"),i=r.litNonce;void 0!==i&&e.setAttribute("nonce",i),e.textContent=a.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,r){this._$AK(t,r)}_$ET(t,e){const r=this.constructor.elementProperties.get(t),a=this.constructor._$Eu(t,r);if(void 0!==a&&!0===r.reflect){const i=(void 0!==r.converter?.toAttribute?r.converter:f).toAttribute(e,r.type);this._$Em=t,null==i?this.removeAttribute(a):this.setAttribute(a,i),this._$Em=null}}_$AK(t,e){const r=this.constructor,a=r._$Eh.get(t);if(void 0!==a&&this._$Em!==a){const t=r.getPropertyOptions(a),i="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:f;this._$Em=a;const o=i.fromAttribute(e,t.type);this[a]=o??this._$Ej?.get(a)??o,this._$Em=null}}requestUpdate(t,e,r){if(void 0!==t){const a=this.constructor,i=this[t];if(r??=a.getPropertyOptions(t),!((r.hasChanged??x)(i,e)||r.useDefault&&r.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(a._$Eu(t,r))))return;this.C(t,e,r)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:r,reflect:a,wrapped:i},o){r&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,o??e??this[t]),!0!==i||void 0!==o)||(this._$AL.has(t)||(this.hasUpdated||r||(e=void 0),this._$AL.set(t,e)),!0===a&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,r]of t){const{wrapped:t}=r,a=this[e];!0!==t||this._$AL.has(e)||void 0===a||this.C(e,void 0,r,a)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}};A.elementStyles=[],A.shadowRootOptions={mode:"open"},A[v("elementProperties")]=new Map,A[v("finalized")]=new Map,b?.({ReactiveElement:A}),(_.reactiveElementVersions??=[]).push("2.1.1");
/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */
const $=globalThis,F=$.trustedTypes,S=F?F.createPolicy("lit-html",{createHTML:t=>t}):void 0,C="$lit$",E=`lit$${Math.random().toFixed(9).slice(2)}$`,k="?"+E,O=`<${k}>`,P=document,D=()=>P.createComment(""),T=t=>null===t||"object"!=typeof t&&"function"!=typeof t,I=Array.isArray,U="[ \t\n\f\r]",R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,q=/-->/g,B=/>/g,L=RegExp(`>|${U}(?:([^\\s"'>=/]+)(${U}*=${U}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),M=/'/g,z=/"/g,N=/^(?:script|style|textarea|title)$/i,H=(t=>(e,...r)=>({_$litType$:t,strings:e,values:r}))(1),j=Symbol.for("lit-noChange"),W=Symbol.for("lit-nothing"),V=new WeakMap,J=P.createTreeWalker(P,129);function K(t,e){if(!I(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const G=(t,e)=>{const r=t.length-1,a=[];let i,o=2===e?"<svg>":3===e?"<math>":"",s=R;for(let e=0;e<r;e++){const r=t[e];let n,c,l=-1,d=0;for(;d<r.length&&(s.lastIndex=d,c=s.exec(r),null!==c);)d=s.lastIndex,s===R?"!--"===c[1]?s=q:void 0!==c[1]?s=B:void 0!==c[2]?(N.test(c[2])&&(i=RegExp("</"+c[2],"g")),s=L):void 0!==c[3]&&(s=L):s===L?">"===c[0]?(s=i??R,l=-1):void 0===c[1]?l=-2:(l=s.lastIndex-c[2].length,n=c[1],s=void 0===c[3]?L:'"'===c[3]?z:M):s===z||s===M?s=L:s===q||s===B?s=R:(s=L,i=void 0);const u=s===L&&t[e+1].startsWith("/>")?" ":"";o+=s===R?r+O:l>=0?(a.push(n),r.slice(0,l)+C+r.slice(l)+E+u):r+E+(-2===l?e:u)}return[K(t,o+(t[r]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),a]};class Q{constructor({strings:t,_$litType$:e},r){let a;this.parts=[];let i=0,o=0;const s=t.length-1,n=this.parts,[c,l]=G(t,e);if(this.el=Q.createElement(c,r),J.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(a=J.nextNode())&&n.length<s;){if(1===a.nodeType){if(a.hasAttributes())for(const t of a.getAttributeNames())if(t.endsWith(C)){const e=l[o++],r=a.getAttribute(t).split(E),s=/([.?@])?(.*)/.exec(e);n.push({type:1,index:i,name:s[2],strings:r,ctor:"."===s[1]?et:"?"===s[1]?rt:"@"===s[1]?at:tt}),a.removeAttribute(t)}else t.startsWith(E)&&(n.push({type:6,index:i}),a.removeAttribute(t));if(N.test(a.tagName)){const t=a.textContent.split(E),e=t.length-1;if(e>0){a.textContent=F?F.emptyScript:"";for(let r=0;r<e;r++)a.append(t[r],D()),J.nextNode(),n.push({type:2,index:++i});a.append(t[e],D())}}}else if(8===a.nodeType)if(a.data===k)n.push({type:2,index:i});else{let t=-1;for(;-1!==(t=a.data.indexOf(E,t+1));)n.push({type:7,index:i}),t+=E.length-1}i++}}static createElement(t,e){const r=P.createElement("template");return r.innerHTML=t,r}}function Z(t,e,r=t,a){if(e===j)return e;let i=void 0!==a?r._$Co?.[a]:r._$Cl;const o=T(e)?void 0:e._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),void 0===o?i=void 0:(i=new o(t),i._$AT(t,r,a)),void 0!==a?(r._$Co??=[])[a]=i:r._$Cl=i),void 0!==i&&(e=Z(t,i._$AS(t,e.values),i,a)),e}class X{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:r}=this._$AD,a=(t?.creationScope??P).importNode(e,!0);J.currentNode=a;let i=J.nextNode(),o=0,s=0,n=r[0];for(;void 0!==n;){if(o===n.index){let e;2===n.type?e=new Y(i,i.nextSibling,this,t):1===n.type?e=new n.ctor(i,n.name,n.strings,this,t):6===n.type&&(e=new it(i,this,t)),this._$AV.push(e),n=r[++s]}o!==n?.index&&(i=J.nextNode(),o++)}return J.currentNode=P,a}p(t){let e=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(t,r,e),e+=r.strings.length-2):r._$AI(t[e])),e++}}class Y{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,r,a){this.type=2,this._$AH=W,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=r,this.options=a,this._$Cv=a?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),T(t)?t===W||null==t||""===t?(this._$AH!==W&&this._$AR(),this._$AH=W):t!==this._$AH&&t!==j&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>I(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==W&&T(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:r}=t,a="number"==typeof r?this._$AC(t):(void 0===r.el&&(r.el=Q.createElement(K(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===a)this._$AH.p(e);else{const t=new X(a,this),r=t.u(this.options);t.p(e),this.T(r),this._$AH=t}}_$AC(t){let e=V.get(t.strings);return void 0===e&&V.set(t.strings,e=new Q(t)),e}k(t){I(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let r,a=0;for(const i of t)a===e.length?e.push(r=new Y(this.O(D()),this.O(D()),this,this.options)):r=e[a],r._$AI(i),a++;a<e.length&&(this._$AR(r&&r._$AB.nextSibling,a),e.length=a)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,r,a,i){this.type=1,this._$AH=W,this._$AN=void 0,this.element=t,this.name=e,this._$AM=a,this.options=i,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=W}_$AI(t,e=this,r,a){const i=this.strings;let o=!1;if(void 0===i)t=Z(this,t,e,0),o=!T(t)||t!==this._$AH&&t!==j,o&&(this._$AH=t);else{const a=t;let s,n;for(t=i[0],s=0;s<i.length-1;s++)n=Z(this,a[r+s],e,s),n===j&&(n=this._$AH[s]),o||=!T(n)||n!==this._$AH[s],n===W?t=W:t!==W&&(t+=(n??"")+i[s+1]),this._$AH[s]=n}o&&!a&&this.j(t)}j(t){t===W?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class et extends tt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===W?void 0:t}}class rt extends tt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==W)}}class at extends tt{constructor(t,e,r,a,i){super(t,e,r,a,i),this.type=5}_$AI(t,e=this){if((t=Z(this,t,e,0)??W)===j)return;const r=this._$AH,a=t===W&&r!==W||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,i=t!==W&&(r===W||a);a&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class it{constructor(t,e,r){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(t){Z(this,t)}}const ot=$.litHtmlPolyfillSupport;ot?.(Q,Y),($.litHtmlVersions??=[]).push("3.3.1");const st=globalThis;
/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */class nt extends A{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,r)=>{const a=r?.renderBefore??e;let i=a._$litPart$;if(void 0===i){const t=r?.renderBefore??null;a._$litPart$=i=new Y(e.insertBefore(D(),t),t,void 0,r??{})}return i._$AI(t),i})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return j}}nt._$litElement$=!0,nt.finalized=!0,st.litElementHydrateSupport?.({LitElement:nt});const ct=st.litElementPolyfillSupport;ct?.({LitElement:nt}),(st.litElementVersions??=[]).push("4.2.1");
/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */
const lt={attribute:!0,type:String,converter:f,reflect:!1,hasChanged:x},dt=(t=lt,e,r)=>{const{kind:a,metadata:i}=r;let o=globalThis.litPropertyMetadata.get(i);if(void 0===o&&globalThis.litPropertyMetadata.set(i,o=new Map),"setter"===a&&((t=Object.create(t)).wrapped=!0),o.set(r.name,t),"accessor"===a){const{name:a}=r;return{set(r){const i=e.get.call(this);e.set.call(this,r),this.requestUpdate(a,i,t)},init(e){return void 0!==e&&this.C(a,void 0,t,e),e}}}if("setter"===a){const{name:a}=r;return function(r){const i=this[a];e.call(this,r),this.requestUpdate(a,i,t)}}throw Error("Unsupported decorator location: "+a)};
/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */function ut(t){return(e,r)=>"object"==typeof r?dt(t,e,r):((t,e,r)=>{const a=e.hasOwnProperty(r);return e.constructor.createProperty(r,t),a?Object.getOwnPropertyDescriptor(e,r):void 0})(t,e,r)}
/**
     * @license
     * Copyright 2017 Google LLC
     * SPDX-License-Identifier: BSD-3-Clause
     */function ht(t){return ut({...t,state:!0,attribute:!1})}class pt{constructor(t){this.config={timeout:3e4,retryAttempts:3,...t},this.defaultHeaders={"Content-Type":"application/json","X-API-Key":t.apiKey}}setBusinessContext(t){this.config.businessId=t}getBusinessContext(){return this.config.businessId}async request(t,e={}){const r=`${this.config.baseURL}${t}`,a={...this.defaultHeaders,...e.headers},i={...e,headers:a,signal:AbortSignal.timeout(this.config.timeout)};try{const t=await fetch(r,i);if(!t.ok){const e=await t.json().catch(()=>({}));return{success:!1,error:e.error||`HTTP ${t.status}: ${t.statusText}`,details:e.details}}return{success:!0,data:await t.json()}}catch(t){return console.error("API Request failed:",t),{success:!1,error:t instanceof Error?t.message:"Network error occurred"}}}async getBusinesses(){return this.request("/v1/businesses/")}async getBusiness(t){return this.request(`/v1/businesses/${t}/`)}async createBusiness(t){return this.request("/v1/businesses/",{method:"POST",body:JSON.stringify(t)})}async updateBusiness(t,e){return this.request(`/v1/businesses/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async getBusinessStats(t){return this.request(`/v1/businesses/${t}/stats/`)}async lookupBusinessByExternalId(t){return this.request(`/v1/businesses/lookup/?external_id=${encodeURIComponent(t)}`)}async getInvoices(t,e){const r=new URLSearchParams({business_id:t});return e?.status&&r.append("status",e.status),e?.customer_id&&r.append("customer_id",e.customer_id),e?.date_from&&r.append("date_from",e.date_from),e?.date_to&&r.append("date_to",e.date_to),e?.overdue&&r.append("overdue","true"),e?.outstanding&&r.append("outstanding","true"),e?.search&&r.append("search",e.search),this.request(`/invoices/?${r.toString()}`)}async getInvoice(t){return this.request(`/invoices/${t}/`)}async createInvoice(t){return this.request("/invoices/",{method:"POST",body:JSON.stringify(t)})}async updateInvoice(t,e){return this.request(`/invoices/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async deleteInvoice(t){return this.request(`/invoices/${t}/`,{method:"DELETE"})}async recordInvoicePayment(t,e){return this.request(`/invoices/${t}/payment/`,{method:"POST",body:JSON.stringify(e)})}async sendInvoice(t){return this.request(`/invoices/${t}/send/`,{method:"POST"})}async getInvoicePayments(t){return this.request(`/invoices/${t}/payments/list/`)}async getCustomers(t){return this.request(`/customers/?business_id=${t}`)}async getCustomer(t){return this.request(`/customers/${t}/`)}async createCustomer(t){return this.request("/customers/",{method:"POST",body:JSON.stringify(t)})}async updateCustomer(t,e){return this.request(`/customers/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async archiveCustomer(t){return this.request(`/customers/${t}/archive/`,{method:"POST"})}async reactivateCustomer(t){return this.request(`/customers/${t}/reactivate/`,{method:"POST"})}async getAccounts(t,e){const r=new URLSearchParams({business_id:t});return e?.account_type&&r.append("account_type",e.account_type),void 0!==e?.is_active&&r.append("is_active",e.is_active.toString()),e?.search&&r.append("search",e.search),this.request(`/accounts/?${r.toString()}`)}async getAccount(t){return this.request(`/accounts/${t}/`)}async createAccount(t){return this.request("/accounts/",{method:"POST",body:JSON.stringify(t)})}async updateAccount(t,e){return this.request(`/accounts/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async deleteAccount(t){return this.request(`/accounts/${t}/`,{method:"DELETE"})}async getBankAccounts(t){return this.request(`/accounts/bank/?business_id=${t}`)}async getAccountHierarchy(t){return this.request(`/accounts/hierarchy/?business_id=${t}`)}async syncAccount(t){return this.request(`/accounts/${t}/sync/`,{method:"POST"})}async getPayments(t,e){const r=new URLSearchParams({business_id:t});return e?.status&&r.append("status",e.status),e?.customer_id&&r.append("customer_id",e.customer_id),e?.date_from&&r.append("date_from",e.date_from),e?.date_to&&r.append("date_to",e.date_to),e?.search&&r.append("search",e.search),this.request(`/payments/?${r.toString()}`)}async getPayment(t){return this.request(`/payments/${t}/`)}async createPayment(t){return this.request("/payments/",{method:"POST",body:JSON.stringify(t)})}async updatePayment(t,e){return this.request(`/payments/${t}/`,{method:"PUT",body:JSON.stringify(e)})}async completePayment(t){return this.request(`/payments/${t}/complete/`,{method:"POST"})}async failPayment(t){return this.request(`/payments/${t}/fail/`,{method:"POST"})}async getBalanceSheet(t,e){const r=new URLSearchParams({business_id:t});return e&&r.append("effective_date",e),this.request(`/reports/balance-sheet/?${r.toString()}`)}async getPnLData(t,e,r){const a=new URLSearchParams({business_id:t,date_from:e,date_to:r});return this.request(`/reports/pnl/?${a.toString()}`)}async getCashFlowData(t,e,r){const a=new URLSearchParams({business_id:t,date_from:e,date_to:r});return this.request(`/reports/cash-flow/?${a.toString()}`)}async healthCheck(){return this.request("/health/")}formatCurrency(t,e="GBP"){const r="number"==typeof t?t:parseFloat(t.toString());return new Intl.NumberFormat("en-GB",{style:"currency",currency:e}).format(r)}formatDate(t){return new Date(t).toLocaleDateString("en-GB",{year:"numeric",month:"short",day:"numeric"})}validateBusinessAccess(t){return this.config.businessId===t||!!t}handleApiError(t){let e="An unexpected error occurred";return 401===t.response?.status?e="Authentication failed. Check your API key.":404===t.response?.status?e="Business not found or not accessible.":403===t.response?.status?e="Permission denied. Business not accessible.":t.response?.data?.error&&(e=t.response.data.error),{success:!1,error:e,details:t.response?.data?.details}}}class yt extends nt{constructor(){super(...arguments),this.apiKey="",this.businessId="",this.theme="light",this.baseUrl="http://localhost:8000/api",this.loading=!1,this.error=null,this.apiClient=null}connectedCallback(){super.connectedCallback(),this.initializeApiClient(),this.loadData()}initializeApiClient(){if("undefined"!=typeof window&&window.FridayProvider){const t=window.FridayProvider.getApiClient();if(t)return void(this.apiClient=t);const e=window.FridayProvider.getWidgetConfig();if(e)return void(this.apiClient=new pt({baseURL:e.baseUrl,apiKey:e.apiKey,businessId:e.businessId}))}this.apiKey?this.apiClient=new pt({baseURL:this.baseUrl,apiKey:this.apiKey,businessId:this.businessId||void 0}):this.setError("API key is required. Configure FridayProvider or provide api-key attribute.")}async loadData(){}setError(t){if(this.error=t,this.loading=!1,this.emitEvent("error",{message:t}),"undefined"!=typeof window&&window.FridayProvider)try{window.FridayProvider.handleError(new Error(t))}catch(t){}}clearError(){this.error=null}handleApiError(t,e="API request"){let r=`${e} failed`;t?.error?r=t.error:t?.message?r=t.message:"string"==typeof t&&(r=t),t?.details&&(r+=` (${t.details})`),this.setError(r),this.emitEvent("api-error",{context:e,error:t,message:r})}async makeApiRequest(t,e="Request"){try{if(this.setLoading(!0),!this.apiClient)throw new Error("API client not initialized");const r=await t();return r.success?(this.clearError(),r.data||null):(this.handleApiError(r,e),null)}catch(t){return this.handleApiError(t,e),null}finally{this.setLoading(!1)}}setLoading(t){this.loading=t,t&&this.clearError()}emitEvent(t,e={}){const r={type:t,data:e,timestamp:Date.now()};this.dispatchEvent(new CustomEvent(`friday-${t}`,{detail:r,bubbles:!0,composed:!0}))}renderLoading(){return H`
      <div class="Friday__loading">
        <div class="Friday__spinner"></div>
        <span>Loading...</span>
      </div>
    `}renderError(){return H`
      <div class="Friday__error">
        <span>⚠️ ${this.error}</span>
      </div>
    `}static get baseStyles(){return n`
      @import url('https://rsms.me/inter/inter.css');

      :host {
        display: block;
        /* Friday Design System - Layer Financial Inspired */
        --color-black: #1a1a1a;
        --color-white: white;
        --color-info: #0968f8;
        --color-info-bg: #d6e6ff;
        --color-info-fg: #0056d7;
        --color-success: hsl(145deg 45% 42%);
        --color-success-bg: hsl(145deg 59% 86%);
        --color-success-fg: hsl(145deg 63% 29%);
        --color-warning: hsl(43deg 100% 44%);
        --color-warning-bg: hsl(43deg 100% 84%);
        --color-warning-fg: hsl(43deg 88% 26%);
        --color-error: hsl(0deg 76% 50%);
        --color-error-bg: hsl(0deg 83% 86%);
        --color-error-fg: hsl(0deg 88% 32%);

        --color-dark-h: 220;
        --color-dark-s: 15%;
        --color-dark-l: 7%;
        --color-dark: hsl(var(--color-dark-h) var(--color-dark-s) var(--color-dark-l));
        
        --color-base-0: #fff;
        --color-base-50: hsl(var(--color-dark-h) 5% 98%);
        --color-base-100: hsl(var(--color-dark-h) 5% 95%);
        --color-base-200: hsl(var(--color-dark-h) 5% 91%);
        --color-base-300: hsl(var(--color-dark-h) 6% 85%);
        --color-base-400: hsl(var(--color-dark-h) 7% 75%);
        --color-base-500: hsl(var(--color-dark-h) 8% 50%);
        --color-base-600: hsl(var(--color-dark-h) 10% 40%);
        --color-base-700: hsl(var(--color-dark-h) 12% 27%);
        --color-base-800: hsl(var(--color-dark-h) 15% 20%);
        --color-base-900: hsl(var(--color-dark-h) 18% 14%);

        --text-color-primary: var(--color-dark);
        --text-color-secondary: var(--color-base-600);
        --text-color-muted: var(--color-base-500);
        --text-color-inverse: var(--color-white);

        --bg-primary: var(--color-base-0);
        --bg-secondary: var(--color-base-50);
        --bg-tertiary: var(--color-base-100);
        --bg-element-hover: var(--color-base-100);

        --border-primary: var(--color-base-200);
        --border-secondary: var(--color-base-300);
        --border-focus: var(--color-info);

        --font-family: 'InterVariable', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        --text-2xs: 10px;
        --text-xs: 11px;
        --text-sm: 12px;
        --text-md: 14px;
        --text-lg: 16px;
        --text-xl: 18px;
        --text-2xl: 20px;
        --text-3xl: 24px;

        --font-weight-normal: 460;
        --font-weight-medium: 500;
        --font-weight-semibold: 540;
        --font-weight-bold: 600;

        --spacing-2xs: 6px;
        --spacing-xs: 8px;
        --spacing-sm: 12px;
        --spacing-md: 16px;
        --spacing-lg: 20px;
        --spacing-xl: 24px;
        --spacing-2xl: 32px;
        --spacing-3xl: 40px;
        --spacing-4xl: 48px;

        --radius-sm: 6px;
        --radius-md: 8px;
        --radius-lg: 12px;

        --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
        --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);

        --transition-fast: 150ms ease;
      }

      .Friday__component {
        font-family: var(--font-family);
        font-size: var(--text-md);
        line-height: 1.5;
        color: var(--text-color-primary);
        background: var(--bg-primary);
        border: 1px solid var(--border-primary);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
        overflow: hidden;
      }

      .Friday__loading {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: var(--spacing-4xl);
        color: var(--text-color-muted);
        font-size: var(--text-sm);
        gap: var(--spacing-xs);
      }

      .Friday__spinner {
        width: 20px;
        height: 20px;
        border: 2px solid var(--border-primary);
        border-top-color: var(--color-info);
        border-radius: 50%;
        animation: Friday__spin 1s linear infinite;
      }

      @keyframes Friday__spin {
        to { transform: rotate(360deg); }
      }

      .Friday__error {
        display: flex;
        align-items: center;
        gap: var(--spacing-xs);
        padding: var(--spacing-md);
        margin: var(--spacing-md);
        background: var(--color-error-bg);
        color: var(--color-error-fg);
        border: 1px solid var(--color-error);
        border-radius: var(--radius-sm);
        font-size: var(--text-sm);
      }

      .Friday__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--spacing-lg) var(--spacing-xl);
        border-bottom: 1px solid var(--border-primary);
        background: var(--bg-secondary);
      }

      .Friday__header-title {
        font-size: var(--text-xl);
        font-weight: var(--font-weight-semibold);
        color: var(--text-color-primary);
        margin: 0;
      }

      .Friday__header-actions {
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
      }

      .Friday__content {
        padding: var(--spacing-xl);
      }

      .Friday__button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: var(--spacing-xs);
        padding: var(--spacing-xs) var(--spacing-md);
        border: 1px solid transparent;
        border-radius: var(--radius-sm);
        font-family: var(--font-family);
        font-size: var(--text-sm);
        font-weight: var(--font-weight-medium);
        line-height: 1.5;
        text-decoration: none;
        cursor: pointer;
        transition: all var(--transition-fast);
        white-space: nowrap;
        user-select: none;
      }

      .Friday__button:disabled {
        opacity: 0.5;
        cursor: not-allowed;
      }

      .Friday__button--primary {
        background: var(--color-info);
        color: var(--text-color-inverse);
        border-color: var(--color-info);
      }

      .Friday__button--primary:hover:not(:disabled) {
        background: var(--color-info-fg);
        border-color: var(--color-info-fg);
      }

      .Friday__button--secondary {
        background: var(--bg-primary);
        color: var(--text-color-primary);
        border-color: var(--border-primary);
      }

      .Friday__button--secondary:hover:not(:disabled) {
        background: var(--bg-element-hover);
        border-color: var(--border-secondary);
      }

      .Friday__button--success {
        background: var(--color-success);
        color: var(--text-color-inverse);
        border-color: var(--color-success);
      }

      .Friday__button--success:hover:not(:disabled) {
        background: var(--color-success-fg);
        border-color: var(--color-success-fg);
      }

      .Friday__button--error {
        background: var(--color-error);
        color: var(--text-color-inverse);
        border-color: var(--color-error);
      }

      .Friday__button--sm {
        padding: var(--spacing-2xs) var(--spacing-sm);
        font-size: var(--text-xs);
      }

      .Friday__input {
        display: block;
        width: 100%;
        padding: var(--spacing-xs) var(--spacing-sm);
        border: 1px solid var(--border-primary);
        border-radius: var(--radius-sm);
        font-family: var(--font-family);
        font-size: var(--text-sm);
        line-height: 1.5;
        color: var(--text-color-primary);
        background: var(--bg-primary);
        transition: all var(--transition-fast);
      }

      .Friday__input:focus {
        outline: none;
        border-color: var(--border-focus);
        box-shadow: 0 0 0 3px hsla(217, 100%, 50%, 0.1);
      }

      .Friday__select {
        display: block;
        width: 100%;
        padding: var(--spacing-xs) var(--spacing-sm);
        border: 1px solid var(--border-primary);
        border-radius: var(--radius-sm);
        font-family: var(--font-family);
        font-size: var(--text-sm);
        color: var(--text-color-primary);
        background: var(--bg-primary);
        cursor: pointer;
        transition: all var(--transition-fast);
      }

      .Friday__table {
        width: 100%;
        border-collapse: collapse;
        font-size: var(--text-sm);
      }

      .Friday__table th,
      .Friday__table td {
        padding: var(--spacing-sm) var(--spacing-md);
        text-align: left;
        border-bottom: 1px solid var(--border-primary);
      }

      .Friday__table th {
        font-weight: var(--font-weight-semibold);
        color: var(--text-color-secondary);
        background: var(--bg-secondary);
        font-size: var(--text-xs);
        text-transform: uppercase;
        letter-spacing: 0.05em;
      }

      .Friday__table tbody tr:hover {
        background: var(--bg-element-hover);
      }

      .Friday__badge {
        display: inline-flex;
        align-items: center;
        padding: 2px var(--spacing-xs);
        border-radius: 9999px;
        font-size: var(--text-2xs);
        font-weight: var(--font-weight-medium);
        text-transform: uppercase;
        letter-spacing: 0.05em;
      }

      .Friday__badge--success {
        background: var(--color-success-bg);
        color: var(--color-success-fg);
      }

      .Friday__badge--warning {
        background: var(--color-warning-bg);
        color: var(--color-warning-fg);
      }

      .Friday__badge--error {
        background: var(--color-error-bg);
        color: var(--color-error-fg);
      }

      .Friday__badge--info {
        background: var(--color-info-bg);
        color: var(--color-info-fg);
      }

      /* Typography utilities */
      .Friday__text-xs { font-size: var(--text-xs); }
      .Friday__text-sm { font-size: var(--text-sm); }
      .Friday__text-md { font-size: var(--text-md); }
      .Friday__text-lg { font-size: var(--text-lg); }
      
      .Friday__text-muted { color: var(--text-color-muted); }
      .Friday__text-secondary { color: var(--text-color-secondary); }

      .Friday__font-medium { font-weight: var(--font-weight-medium); }
      .Friday__font-semibold { font-weight: var(--font-weight-semibold); }
      .Friday__font-bold { font-weight: var(--font-weight-bold); }

      @media (max-width: 768px) {
        .Friday__component {
          border-radius: 0;
          border-left: none;
          border-right: none;
          box-shadow: none;
        }
        
        .Friday__header {
          padding: var(--spacing-md) var(--spacing-lg);
        }
        
        .Friday__content {
          padding: var(--spacing-lg);
        }
        
        .Friday__table th,
        .Friday__table td {
          padding: var(--spacing-xs) var(--spacing-sm);
        }
      }
    `}}return e([ut({type:String,attribute:"api-key"})],yt.prototype,"apiKey",void 0),e([ut({type:String,attribute:"business-id"})],yt.prototype,"businessId",void 0),e([ut({type:String})],yt.prototype,"theme",void 0),e([ut({type:String,attribute:"base-url"})],yt.prototype,"baseUrl",void 0),e([ht()],yt.prototype,"loading",void 0),e([ht()],yt.prototype,"error",void 0),t.ChartOfAccountsWidget=class extends yt{constructor(){super(...arguments),this.asWidget=!1,this.withDateControl=!1,this.withExpandAllButton=!1,this.balanceDate=(new Date).toISOString().split("T")[0],this.showDemo=!1,this.accounts=[],this.filteredAccounts=[],this.searchQuery="",this.selectedAccountType="",this.isAllExpanded=!1,this.showAccountForm=!1,this.formMode="create",this.formData={code:"",custom_name:"",account_type:"",account_subtype:"",parent_account_id:"",description:""},this.isLoading=!1,this.error=null,this.hoveredRowId=null}async connectedCallback(){super.connectedCallback(),await this.loadAccounts()}async loadAccounts(){if(this.showDemo)return void this.loadDemoData();if(!this.apiClient)return void this.setError("API client not initialized");const t=this.apiClient.getBusinessContext();if(!t)return void this.setError("Business context is required. Please configure FridayProvider with businessId.");const e=await this.makeApiRequest(()=>this.apiClient.getAccounts(t),"Loading chart of accounts");e&&(this.accounts=this.buildAccountHierarchy(e.results.map(t=>({...t,balance_date:this.balanceDate}))),this.filteredAccounts=[...this.accounts],this.emitEvent("accounts-loaded",{count:e.results.length,hierarchyCount:this.accounts.length}))}buildAccountHierarchy(t){const e=new Map,r=[];return t.forEach(t=>{e.set(t.id,{...t,children:[]})}),t.forEach(t=>{const a=e.get(t.id);if(t.parent_account){const r=e.get(t.parent_account);r&&r.children.push(a)}else r.push(a)}),r.sort((t,e)=>t.code.localeCompare(e.code))}loadDemoData(){const t=[{id:"1",business_id:"demo",code:"1000",name:"Current Assets",account_type:"current_asset",account_subtype:"checking",is_active:!0,normal_balance:"debit",current_balance:4500,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"2",business_id:"demo",code:"1001",name:"Business Current Account",account_type:"current_asset",account_subtype:"checking",parent_account_id:"1",is_active:!0,normal_balance:"debit",current_balance:1250,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"3",business_id:"demo",code:"1002",name:"Business Savings Account",account_type:"current_asset",account_subtype:"savings",parent_account_id:"1",is_active:!0,normal_balance:"debit",current_balance:750,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"4",business_id:"demo",code:"1200",name:"Accounts Receivable",account_type:"current_asset",account_subtype:"receivables",parent_account_id:"1",is_active:!0,normal_balance:"debit",current_balance:2500,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"5",business_id:"demo",code:"4000",name:"Revenue",account_type:"revenue",account_subtype:"sales",is_active:!0,normal_balance:"credit",current_balance:-8500,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"6",business_id:"demo",code:"4100",name:"Sales Revenue",account_type:"revenue",account_subtype:"sales",parent_account_id:"5",is_active:!0,normal_balance:"credit",current_balance:-6500,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"7",business_id:"demo",code:"4200",name:"Service Revenue",account_type:"revenue",account_subtype:"services",parent_account_id:"5",is_active:!0,normal_balance:"credit",current_balance:-2e3,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"8",business_id:"demo",code:"6000",name:"Operating Expenses",account_type:"operating_expense",account_subtype:"operational",is_active:!0,normal_balance:"debit",current_balance:1800,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"9",business_id:"demo",code:"6100",name:"Office Rent",account_type:"operating_expense",account_subtype:"operational",parent_account_id:"8",is_active:!0,normal_balance:"debit",current_balance:360,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"10",business_id:"demo",code:"6200",name:"Marketing & Advertising",account_type:"operating_expense",account_subtype:"operational",parent_account_id:"8",is_active:!0,normal_balance:"debit",current_balance:480,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]},{id:"11",business_id:"demo",code:"6300",name:"Professional Services",account_type:"operating_expense",account_subtype:"operational",parent_account_id:"8",is_active:!0,normal_balance:"debit",current_balance:960,balance_date:this.balanceDate,created_at:(new Date).toISOString(),updated_at:(new Date).toISOString(),children:[]}];this.accounts=this.buildAccountHierarchy(t),this.filteredAccounts=[...this.accounts]}handleSearch(t){const e=t.target;this.searchQuery=e.value.toLowerCase(),this.filterAccounts()}handleTypeFilter(t){const e=t.target;this.selectedAccountType=e.value,this.filterAccounts()}handleDateChange(t){const e=t.target;this.balanceDate=e.value,this.loadAccounts()}filterAccounts(){let t=[...this.accounts];this.searchQuery&&(t=this.filterAccountsBySearch(t,this.searchQuery)),this.selectedAccountType&&(t=this.filterAccountsByType(t,this.selectedAccountType)),this.filteredAccounts=t}filterAccountsBySearch(t,e){return t.filter(t=>{if(t.name.toLowerCase().includes(e)||t.code.toLowerCase().includes(e)||t.account_subtype?.toLowerCase().includes(e))return!0;if(t.children?.length){const r=this.filterAccountsBySearch(t.children,e);if(r.length>0)return t.children=r,!0}return!1})}filterAccountsByType(t,e){return t.filter(t=>{if(t.account_type===e)return!0;if(t.children?.length){const r=this.filterAccountsByType(t.children,e);if(r.length>0)return t.children=r,!0}return!1})}toggleExpand(t){t.is_expanded=!t.is_expanded,this.requestUpdate()}toggleExpandAll(){this.isAllExpanded=!this.isAllExpanded,this.expandAllAccounts(this.filteredAccounts,this.isAllExpanded),this.requestUpdate()}expandAllAccounts(t,e){t.forEach(t=>{t.is_expanded=e,t.children?.length&&this.expandAllAccounts(t.children,e)})}openAccountForm(t,e){this.formMode=t,this.selectedAccount=e,this.formData="edit"===t&&e?{code:e.code,custom_name:e.name,account_type:e.account_type,account_subtype:e.account_subtype||"",parent_account_id:e.parent_account_id||"",description:e.description||""}:{code:"",custom_name:"",account_type:"",account_subtype:"",parent_account_id:"",description:""},this.showAccountForm=!0,document.body.style.overflow="hidden"}closeAccountForm(){this.showAccountForm=!1,this.selectedAccount=void 0,document.body.style.overflow=""}async saveAccount(){if(!this.apiClient)return;const t=this.apiClient.getBusinessContext();if(!t)return void this.setError("Business context is required");const e={...this.formData,business_id:t};if("create"===this.formMode){const t=await this.makeApiRequest(()=>this.apiClient.createAccount(e),"Creating account");t&&(this.emitEvent("account-created",t),this.closeAccountForm(),await this.loadAccounts())}else{const t=await this.makeApiRequest(()=>this.apiClient.updateAccount(this.selectedAccount.id,e),"Updating account");t&&(this.emitEvent("account-updated",t),this.closeAccountForm(),await this.loadAccounts())}}async exportCSV(){try{const t=this.generateCSVContent(),e=new Blob([t],{type:"text/csv"}),r=window.URL.createObjectURL(e),a=document.createElement("a");a.href=r,a.download=`chart-of-accounts-${this.balanceDate}.csv`,document.body.appendChild(a),a.click(),window.URL.revokeObjectURL(r),document.body.removeChild(a),this.dispatchEvent(new CustomEvent("friday-accounts-exported",{detail:{format:"csv",date:this.balanceDate},bubbles:!0}))}catch(t){console.error("Error exporting accounts:",t)}}generateCSVContent(){const t=[["Code","Name","Type","Subtype","Balance","Parent Code"].join(",")],e=(r,a="")=>{r.forEach(r=>{const i=[r.code,`"${r.name}"`,r.account_type,r.account_subtype||"",this.formatCurrency(r.current_balance),a];t.push(i.join(",")),r.children?.length&&e(r.children,r.code)})};return e(this.filteredAccounts),t.join("\n")}formatCurrency(t){return new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP"}).format(t)}formatAccountType(t){return t.replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}getAccountTypeBadgeClass(t){return`Friday__account-type-badge--${{current_asset:"asset",fixed_asset:"asset",other_asset:"asset",current_liability:"liability",long_term_liability:"liability",equity:"equity",revenue:"revenue",operating_expense:"expense",cost_of_goods_sold:"expense"}[t]||"default"}`}getBalanceClass(t){return t>0?"Friday__account-balance--positive":t<0?"Friday__account-balance--negative":"Friday__account-balance--zero"}renderAccountRow(t,e=0){const r=t.children&&t.children.length>0,a=t.is_expanded,i=0===e&&r;return H`
      <tr class="Friday__table-row ${i?"Friday__table-row--parent":"Friday__table-row--child"}"
          @mouseenter=${()=>this.hoveredRowId=t.id}
          @mouseleave=${()=>this.hoveredRowId=null}>
        
        <td class="Friday__table-cell Friday__chart-of-accounts--name">
          <div class="Friday__account-name-cell" style="padding-left: ${1.5*e}rem">
            ${r?H`
              <button 
                class="Friday__expand-button ${a?"Friday__expand-button--expanded":""}"
                @click=${()=>this.toggleExpand(t)}
                title="${a?"Collapse":"Expand"} ${t.name}"
              >
                ${a?"−":"+"}
              </button>
            `:H`<div style="width: 1.5rem;"></div>`}
            
            <div class="Friday__account-info">
              <div class="Friday__account-code">${t.code}</div>
              <div class="Friday__account-name ${i?"Friday__account-name--parent":""}">${t.name}</div>
            </div>
          </div>
        </td>
        
        <td class="Friday__table-cell Friday__chart-of-accounts--type">
          <span class="Friday__account-type-badge ${this.getAccountTypeBadgeClass(t.account_type)}">
            ${this.formatAccountType(t.account_type)}
          </span>
        </td>
        
        <td class="Friday__table-cell Friday__chart-of-accounts--subtype">
          ${t.account_subtype?this.formatAccountType(t.account_subtype):"—"}
        </td>
        
        <td class="Friday__table-cell Friday__chart-of-accounts--balance">
          <span class="Friday__account-balance ${this.getBalanceClass(t.current_balance)}">
            ${this.formatCurrency(t.current_balance)}
          </span>
        </td>
        
        <td class="Friday__table-cell Friday__chart-of-accounts--actions">
          <div class="Friday__row-actions">
            <button 
              class="Friday__action-btn"
              @click=${()=>this.openAccountForm("edit",t)}
              title="Edit ${t.name}"
            >
              <svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor">
                <path d="M10.5 3.5L2.5 11.5V12.5H3.5L11.5 4.5L10.5 3.5ZM12.2 2.8L11.2 1.8C11 1.6 10.7 1.6 10.5 1.8L9.5 2.8L11.2 4.5L12.2 3.5C12.4 3.3 12.4 3 12.2 2.8Z"/>
              </svg>
            </button>
          </div>
        </td>
      </tr>
      
      ${r&&a?t.children.map(t=>this.renderAccountRow(t,e+1)):""}
    `}renderAccountForm(){return this.showAccountForm?H`
      <div class="Friday__backdrop ${this.showAccountForm?"Friday__backdrop--visible":""}"
           @click=${this.closeAccountForm}></div>
      
      <div class="Friday__sidebar ${this.showAccountForm?"Friday__sidebar--open":""}">
        <div class="Friday__sidebar__header">
          <h3 class="Friday__sidebar__title">
            ${"create"===this.formMode?"Create Account":"Edit Account"}
          </h3>
          <button 
            class="Friday__close-btn"
            @click=${this.closeAccountForm}
            title="Close"
          >
            <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
              <path d="M12 4L4 12M4 4L12 12" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
            </svg>
          </button>
        </div>
        
        <form class="Friday__form" @submit=${t=>{t.preventDefault(),this.saveAccount()}}>
          <div class="Friday__form-group">
            <label class="Friday__form-label" for="account-code">Account Code *</label>
            <input
              id="account-code"
              class="Friday__form-input"
              type="text"
              .value=${this.formData.code}
              @input=${t=>this.formData.code=t.target.value}
              placeholder="e.g., 1000"
              required
            />
          </div>
          
          <div class="Friday__form-group">
            <label class="Friday__form-label" for="account-name">Account Name *</label>
            <input
              id="account-name"
              class="Friday__form-input"
              type="text"
              .value=${this.formData.custom_name}
              @input=${t=>this.formData.custom_name=t.target.value}
              placeholder="e.g., Business Current Account"
              required
            />
          </div>
          
          <div class="Friday__form-group">
            <label class="Friday__form-label" for="account-type">Account Type *</label>
            <select
              id="account-type"
              class="Friday__form-input"
              .value=${this.formData.account_type}
              @change=${t=>this.formData.account_type=t.target.value}
              required
            >
              <option value="">Select Type</option>
              <option value="current_asset">Current Asset</option>
              <option value="fixed_asset">Fixed Asset</option>
              <option value="other_asset">Other Asset</option>
              <option value="current_liability">Current Liability</option>
              <option value="long_term_liability">Long-term Liability</option>
              <option value="equity">Owner's Equity</option>
              <option value="revenue">Revenue</option>
              <option value="operating_expense">Operating Expense</option>
              <option value="cost_of_goods_sold">Cost of Goods Sold</option>
            </select>
          </div>
          
          <div class="Friday__form-group">
            <label class="Friday__form-label" for="account-subtype">Account Subtype</label>
            <select
              id="account-subtype"
              class="Friday__form-input"
              .value=${this.formData.account_subtype}
              @change=${t=>this.formData.account_subtype=t.target.value}
            >
              <option value="">Select Subtype</option>
              <option value="checking">Checking Account</option>
              <option value="savings">Savings Account</option>
              <option value="cash">Cash</option>
              <option value="receivables">Accounts Receivable</option>
              <option value="inventory">Inventory</option>
              <option value="equipment">Equipment</option>
              <option value="payables">Accounts Payable</option>
              <option value="tax_liability">Tax Liability</option>
              <option value="sales">Sales Revenue</option>
              <option value="services">Service Revenue</option>
              <option value="operational">Operating Expenses</option>
            </select>
          </div>
          
          <div class="Friday__form-group">
            <label class="Friday__form-label" for="description">Description</label>
            <textarea
              id="description"
              class="Friday__form-input Friday__form-textarea"
              .value=${this.formData.description}
              @input=${t=>this.formData.description=t.target.value}
              placeholder="Optional description for this account"
            ></textarea>
          </div>
        </form>
        
        <div class="Friday__form-actions">
          <button type="button" class="Friday__btn Friday__btn--secondary" @click=${this.closeAccountForm}>
            Cancel
          </button>
          <button type="submit" class="Friday__btn Friday__btn--primary" @click=${this.saveAccount}>
            ${"create"===this.formMode?"Create Account":"Update Account"}
          </button>
        </div>
      </div>
    `:""}render(){return this.isLoading?H`
        <div class="Friday__component-container">
          <div class="Friday__loading">
            <div class="Friday__spinner"></div>
            <div>Loading accounts...</div>
          </div>
        </div>
      `:this.error?H`
        <div class="Friday__component-container">
          <div class="Friday__error">
            <strong>Error:</strong> ${this.error}
          </div>
        </div>
      `:H`
      <div class="Friday__component-container">
        <div class="Friday__chart-of-accounts__panel">
          ${this.asWidget?"":H`
            <div class="Friday__chart-of-accounts__header">
              <h2 class="Friday__chart-of-accounts__title">Chart of Accounts</h2>
              <div class="Friday__header-actions">
                <button 
                  class="Friday__btn Friday__btn--secondary"
                  @click=${this.exportCSV}
                  title="Export to CSV"
                >
                  <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
                    <path d="M14 6V2a1 1 0 0 0-1-1H3a1 1 0 0 0-1 1v4M2 14h12M8 10l-3-3M8 10l3-3M8 10V2"/>
                  </svg>
                  Export CSV
                </button>
                <button 
                  class="Friday__btn Friday__btn--primary"
                  @click=${()=>this.openAccountForm("create")}
                >
                  <svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
                    <path d="M8 2V14M2 8H14" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
                  </svg>
                  Add Account
                </button>
              </div>
            </div>
          `}
          
          <div class="Friday__chart-of-accounts__toolbar">
            <div class="Friday__toolbar-left">
              <div class="Friday__search-field">
                <svg class="Friday__search-icon" viewBox="0 0 16 16" fill="currentColor">
                  <path d="M11.5 7a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0ZM15.5 15l-3-3"/>
                </svg>
                <input
                  class="Friday__search-input"
                  type="text"
                  placeholder="Search accounts..."
                  .value=${this.searchQuery}
                  @input=${this.handleSearch}
                />
              </div>
              
              <select
                class="Friday__filter-select"
                .value=${this.selectedAccountType}
                @change=${this.handleTypeFilter}
              >
                <option value="">All Account Types</option>
                <option value="current_asset">Current Assets</option>
                <option value="fixed_asset">Fixed Assets</option>
                <option value="other_asset">Other Assets</option>
                <option value="current_liability">Current Liabilities</option>
                <option value="long_term_liability">Long-term Liabilities</option>
                <option value="equity">Owner's Equity</option>
                <option value="revenue">Revenue</option>
                <option value="operating_expense">Operating Expenses</option>
                <option value="cost_of_goods_sold">Cost of Goods Sold</option>
              </select>
            </div>
            
            <div class="Friday__toolbar-right">
              ${this.withDateControl?H`
                <div class="Friday__date-control">
                  <label class="Friday__date-label" for="balance-date">Balance Date:</label>
                  <input
                    id="balance-date"
                    class="Friday__date-input"
                    type="date"
                    .value=${this.balanceDate}
                    @change=${this.handleDateChange}
                  />
                </div>
              `:""}
              
              ${this.withExpandAllButton?H`
                <button 
                  class="Friday__btn Friday__btn--ghost"
                  @click=${this.toggleExpandAll}
                  title="${this.isAllExpanded?"Collapse all accounts":"Expand all accounts"}"
                >
                  ${this.isAllExpanded?"Collapse All":"Expand All"}
                </button>
              `:""}
            </div>
          </div>
          
          <div class="Friday__chart-of-accounts__content">
            ${0===this.filteredAccounts.length?H`
              <div class="Friday__empty-state">
                <div class="Friday__empty-state__icon">📊</div>
                <h3 class="Friday__empty-state__title">No accounts found</h3>
                <p class="Friday__empty-state__description">
                  Try adjusting your search or filters, or create your first account to get started.
                </p>
              </div>
            `:H`
              <table class="Friday__chart-of-accounts__table">
                <thead class="Friday__table-header">
                  <tr>
                    <th class="Friday__chart-of-accounts--name">Account</th>
                    <th class="Friday__chart-of-accounts--type">Type</th>
                    <th class="Friday__chart-of-accounts--subtype">Subtype</th>
                    <th class="Friday__chart-of-accounts--balance">Balance</th>
                    <th class="Friday__chart-of-accounts--actions">Actions</th>
                  </tr>
                </thead>
                <tbody>
                  ${this.filteredAccounts.map(t=>this.renderAccountRow(t))}
                </tbody>
              </table>
            `}
          </div>
        </div>
      </div>
      
      ${this.renderAccountForm()}
    `}},t.ChartOfAccountsWidget.styles=[yt.styles||[],n`
      /* Layer-inspired Chart of Accounts - Professional UI */
      
      :host {
        --layer-primary: hsl(220, 91%, 56%);
        --layer-primary-hover: hsl(220, 91%, 50%);
        --layer-primary-light: hsl(220, 91%, 96%);
        --layer-success: hsl(142, 71%, 45%);
        --layer-warning: hsl(38, 92%, 50%);
        --layer-error: hsl(0, 84%, 60%);
        
        --layer-gray-50: hsl(210, 20%, 98%);
        --layer-gray-100: hsl(220, 14%, 96%);
        --layer-gray-200: hsl(220, 13%, 91%);
        --layer-gray-300: hsl(216, 12%, 84%);
        --layer-gray-400: hsl(218, 11%, 65%);
        --layer-gray-500: hsl(220, 9%, 46%);
        --layer-gray-600: hsl(215, 14%, 34%);
        --layer-gray-700: hsl(217, 19%, 27%);
        --layer-gray-800: hsl(215, 28%, 17%);
        --layer-gray-900: hsl(221, 39%, 11%);
        
        --layer-spacing-xs: 0.25rem;
        --layer-spacing-sm: 0.5rem;
        --layer-spacing-md: 0.75rem;
        --layer-spacing-lg: 1rem;
        --layer-spacing-xl: 1.5rem;
        --layer-spacing-2xl: 2rem;
        --layer-spacing-3xl: 3rem;
        
        --layer-radius-sm: 0.375rem;
        --layer-radius-md: 0.5rem;
        --layer-radius-lg: 0.75rem;
        
        --layer-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
        --layer-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        --layer-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        
        --layer-font-family: 'InterVariable', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        --layer-transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
      }

      .Friday__component-container {
        position: relative;
        display: flex;
        align-items: stretch;
        overflow: hidden;
        background: white;
        border-radius: var(--layer-radius-lg);
        box-shadow: var(--layer-shadow-md);
        font-family: var(--layer-font-family);
        min-height: 600px;
      }

      /* Main Panel */
      .Friday__chart-of-accounts__panel {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
      }

      /* Header */
      .Friday__chart-of-accounts__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--layer-spacing-xl);
        border-bottom: 1px solid var(--layer-gray-200);
        background: var(--layer-gray-50);
      }

      .Friday__chart-of-accounts__title {
        font-size: 1.5rem;
        font-weight: 600;
        color: var(--layer-gray-900);
        margin: 0;
        line-height: 1.25;
      }

      .Friday__header-actions {
        display: flex;
        align-items: center;
        gap: var(--layer-spacing-md);
      }

      /* Toolbar */
      .Friday__chart-of-accounts__toolbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--layer-spacing-lg) var(--layer-spacing-xl);
        border-bottom: 1px solid var(--layer-gray-200);
        background: white;
        gap: var(--layer-spacing-lg);
      }

      .Friday__toolbar-left {
        display: flex;
        align-items: center;
        gap: var(--layer-spacing-md);
        flex: 1;
      }

      .Friday__toolbar-right {
        display: flex;
        align-items: center;
        gap: var(--layer-spacing-md);
      }

      /* Search Field - Layer Style */
      .Friday__search-field {
        position: relative;
        width: 240px;
      }

      .Friday__search-input {
        width: 100%;
        padding: var(--layer-spacing-sm) var(--layer-spacing-md);
        padding-left: 2.5rem;
        border: 1px solid var(--layer-gray-300);
        border-radius: var(--layer-radius-md);
        font-size: 0.875rem;
        color: var(--layer-gray-900);
        background: white;
        transition: var(--layer-transition);
      }

      .Friday__search-input:focus {
        outline: none;
        border-color: var(--layer-primary);
        box-shadow: 0 0 0 3px var(--layer-primary-light);
      }

      .Friday__search-input::placeholder {
        color: var(--layer-gray-400);
      }

      .Friday__search-icon {
        position: absolute;
        left: var(--layer-spacing-sm);
        top: 50%;
        transform: translateY(-50%);
        color: var(--layer-gray-400);
        width: 1rem;
        height: 1rem;
      }

      /* Filter Select */
      .Friday__filter-select {
        padding: var(--layer-spacing-sm) var(--layer-spacing-md);
        border: 1px solid var(--layer-gray-300);
        border-radius: var(--layer-radius-md);
        font-size: 0.875rem;
        color: var(--layer-gray-900);
        background: white;
        cursor: pointer;
        transition: var(--layer-transition);
        min-width: 160px;
      }

      .Friday__filter-select:focus {
        outline: none;
        border-color: var(--layer-primary);
        box-shadow: 0 0 0 3px var(--layer-primary-light);
      }

      /* Date Control */
      .Friday__date-control {
        display: flex;
        align-items: center;
        gap: var(--layer-spacing-sm);
      }

      .Friday__date-label {
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--layer-gray-700);
        white-space: nowrap;
      }

      .Friday__date-input {
        padding: var(--layer-spacing-sm) var(--layer-spacing-md);
        border: 1px solid var(--layer-gray-300);
        border-radius: var(--layer-radius-md);
        font-size: 0.875rem;
        color: var(--layer-gray-900);
        background: white;
        transition: var(--layer-transition);
      }

      .Friday__date-input:focus {
        outline: none;
        border-color: var(--layer-primary);
        box-shadow: 0 0 0 3px var(--layer-primary-light);
      }

      /* Buttons - Layer Style */
      .Friday__btn {
        display: inline-flex;
        align-items: center;
        gap: var(--layer-spacing-sm);
        padding: var(--layer-spacing-sm) var(--layer-spacing-lg);
        border: none;
        border-radius: var(--layer-radius-md);
        font-size: 0.875rem;
        font-weight: 500;
        font-family: inherit;
        cursor: pointer;
        transition: var(--layer-transition);
        text-decoration: none;
        white-space: nowrap;
      }

      .Friday__btn--primary {
        background: var(--layer-primary);
        color: white;
      }

      .Friday__btn--primary:hover {
        background: var(--layer-primary-hover);
        transform: translateY(-1px);
        box-shadow: var(--layer-shadow-md);
      }

      .Friday__btn--secondary {
        background: white;
        color: var(--layer-gray-700);
        border: 1px solid var(--layer-gray-300);
      }

      .Friday__btn--secondary:hover {
        background: var(--layer-gray-50);
        border-color: var(--layer-gray-400);
        transform: translateY(-1px);
        box-shadow: var(--layer-shadow-sm);
      }

      .Friday__btn--ghost {
        background: transparent;
        color: var(--layer-gray-600);
        padding: var(--layer-spacing-xs) var(--layer-spacing-sm);
      }

      .Friday__btn--ghost:hover {
        background: var(--layer-gray-100);
        color: var(--layer-gray-900);
      }

      /* Table Container */
      .Friday__chart-of-accounts__content {
        flex: 1;
        overflow: auto;
        background: white;
      }

      /* Table - Professional Layer Style */
      .Friday__chart-of-accounts__table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
      }

      .Friday__table-header {
        background: var(--layer-gray-50);
        position: sticky;
        top: 0;
        z-index: 10;
      }

      .Friday__table-header th {
        padding: var(--layer-spacing-md) var(--layer-spacing-lg);
        text-align: left;
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--layer-gray-600);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        border-bottom: 1px solid var(--layer-gray-200);
        white-space: nowrap;
      }

      .Friday__table-header .Friday__chart-of-accounts--name {
        width: auto;
        min-width: 20rem;
      }

      .Friday__table-header .Friday__chart-of-accounts--type {
        width: 10rem;
      }

      .Friday__table-header .Friday__chart-of-accounts--subtype {
        width: 12rem;
      }

      .Friday__table-header .Friday__chart-of-accounts--balance {
        width: 12rem;
        text-align: right;
      }

      .Friday__table-header .Friday__chart-of-accounts--actions {
        width: 8rem;
        text-align: center;
      }

      /* Table Rows */
      .Friday__table-row {
        border-bottom: 1px solid var(--layer-gray-100);
        transition: var(--layer-transition);
        cursor: pointer;
      }

      .Friday__table-row:hover {
        background: var(--layer-gray-50);
      }

      .Friday__table-row--parent {
        background: var(--layer-gray-25);
        font-weight: 500;
      }

      .Friday__table-row--parent:hover {
        background: var(--layer-gray-75);
      }

      .Friday__table-row--child {
        background: white;
      }

      .Friday__table-cell {
        padding: var(--layer-spacing-md) var(--layer-spacing-lg);
        vertical-align: middle;
        font-size: 0.875rem;
        color: var(--layer-gray-900);
      }

      /* Account Name Cell */
      .Friday__account-name-cell {
        display: flex;
        align-items: center;
        gap: var(--layer-spacing-sm);
      }

      .Friday__expand-button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 1.5rem;
        height: 1.5rem;
        background: none;
        border: 1px solid var(--layer-gray-300);
        border-radius: var(--layer-radius-sm);
        cursor: pointer;
        transition: var(--layer-transition);
        color: var(--layer-gray-500);
        font-size: 0.75rem;
      }

      .Friday__expand-button:hover {
        background: var(--layer-primary-light);
        border-color: var(--layer-primary);
        color: var(--layer-primary);
        transform: scale(1.1);
      }

      .Friday__expand-button--expanded {
        background: var(--layer-primary);
        border-color: var(--layer-primary);
        color: white;
      }

      .Friday__account-info {
        display: flex;
        flex-direction: column;
        gap: 0.125rem;
      }

      .Friday__account-code {
        font-family: 'SF Mono', Monaco, Consolas, monospace;
        color: var(--layer-gray-500);
        font-size: 0.75rem;
        font-weight: 500;
      }

      .Friday__account-name {
        color: var(--layer-gray-900);
        font-weight: 500;
        line-height: 1.25;
      }

      .Friday__account-name--parent {
        font-weight: 600;
        color: var(--layer-gray-800);
      }

      /* Type Badges */
      .Friday__account-type-badge {
        display: inline-flex;
        align-items: center;
        padding: 0.25rem 0.5rem;
        background: var(--layer-gray-100);
        border: 1px solid var(--layer-gray-200);
        border-radius: var(--layer-radius-sm);
        font-size: 0.75rem;
        font-weight: 500;
        color: var(--layer-gray-700);
        text-transform: capitalize;
        white-space: nowrap;
      }

      .Friday__account-type-badge--asset {
        background: hsl(142, 71%, 95%);
        border-color: hsl(142, 71%, 85%);
        color: hsl(142, 71%, 35%);
      }

      .Friday__account-type-badge--liability {
        background: hsl(0, 84%, 95%);
        border-color: hsl(0, 84%, 85%);
        color: hsl(0, 84%, 45%);
      }

      .Friday__account-type-badge--equity {
        background: hsl(220, 91%, 95%);
        border-color: hsl(220, 91%, 85%);
        color: hsl(220, 91%, 45%);
      }

      .Friday__account-type-badge--revenue {
        background: hsl(142, 71%, 95%);
        border-color: hsl(142, 71%, 85%);
        color: hsl(142, 71%, 35%);
      }

      .Friday__account-type-badge--expense {
        background: hsl(38, 92%, 95%);
        border-color: hsl(38, 92%, 85%);
        color: hsl(38, 92%, 35%);
      }

      /* Balance Display */
      .Friday__account-balance {
        font-family: 'SF Mono', Monaco, Consolas, monospace;
        text-align: right;
        font-weight: 600;
        font-size: 0.875rem;
      }

      .Friday__account-balance--positive {
        color: var(--layer-success);
      }

      .Friday__account-balance--negative {
        color: var(--layer-error);
      }

      .Friday__account-balance--zero {
        color: var(--layer-gray-400);
      }

      /* Action Buttons */
      .Friday__row-actions {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: var(--layer-spacing-xs);
        opacity: 0;
        transition: var(--layer-transition);
      }

      .Friday__table-row:hover .Friday__row-actions {
        opacity: 1;
      }

      .Friday__action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        background: white;
        border: 1px solid var(--layer-gray-300);
        border-radius: var(--layer-radius-sm);
        cursor: pointer;
        transition: var(--layer-transition);
        color: var(--layer-gray-500);
      }

      .Friday__action-btn:hover {
        background: var(--layer-primary-light);
        border-color: var(--layer-primary);
        color: var(--layer-primary);
        transform: scale(1.1);
      }

      /* Sidebar */
      .Friday__sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 28rem;
        height: 100vh;
        background: white;
        border-left: 1px solid var(--layer-gray-200);
        box-shadow: var(--layer-shadow-lg);
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
      }

      .Friday__sidebar--open {
        transform: translateX(0);
      }

      .Friday__sidebar__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--layer-spacing-xl);
        border-bottom: 1px solid var(--layer-gray-200);
        background: var(--layer-gray-50);
      }

      .Friday__sidebar__title {
        font-size: 1.25rem;
        font-weight: 600;
        color: var(--layer-gray-900);
        margin: 0;
      }

      .Friday__close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        background: none;
        border: none;
        border-radius: var(--layer-radius-sm);
        cursor: pointer;
        transition: var(--layer-transition);
        color: var(--layer-gray-500);
      }

      .Friday__close-btn:hover {
        background: var(--layer-gray-200);
        color: var(--layer-gray-700);
      }

      /* Form */
      .Friday__form {
        flex: 1;
        padding: var(--layer-spacing-xl);
        overflow-y: auto;
      }

      .Friday__form-group {
        margin-bottom: var(--layer-spacing-lg);
      }

      .Friday__form-label {
        display: block;
        margin-bottom: var(--layer-spacing-sm);
        font-weight: 500;
        color: var(--layer-gray-700);
        font-size: 0.875rem;
      }

      .Friday__form-input {
        width: 100%;
        padding: var(--layer-spacing-md);
        border: 1px solid var(--layer-gray-300);
        border-radius: var(--layer-radius-md);
        font-size: 0.875rem;
        color: var(--layer-gray-900);
        background: white;
        transition: var(--layer-transition);
        font-family: inherit;
      }

      .Friday__form-input:focus {
        outline: none;
        border-color: var(--layer-primary);
        box-shadow: 0 0 0 3px var(--layer-primary-light);
      }

      .Friday__form-textarea {
        min-height: 6rem;
        resize: vertical;
        font-family: inherit;
      }

      .Friday__form-actions {
        display: flex;
        gap: var(--layer-spacing-md);
        justify-content: flex-end;
        padding: var(--layer-spacing-xl);
        border-top: 1px solid var(--layer-gray-200);
        background: var(--layer-gray-50);
      }

      /* Loading State */
      .Friday__loading {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: var(--layer-spacing-3xl);
        color: var(--layer-gray-500);
      }

      .Friday__spinner {
        width: 2rem;
        height: 2rem;
        border: 2px solid var(--layer-gray-200);
        border-top-color: var(--layer-primary);
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: var(--layer-spacing-lg);
      }

      @keyframes spin {
        to {
          transform: rotate(360deg);
        }
      }

      /* Error State */
      .Friday__error {
        padding: var(--layer-spacing-lg);
        background: hsl(0, 84%, 95%);
        border: 1px solid hsl(0, 84%, 85%);
        border-radius: var(--layer-radius-md);
        color: hsl(0, 84%, 45%);
        margin: var(--layer-spacing-lg);
        font-size: 0.875rem;
      }

      /* Empty State */
      .Friday__empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: var(--layer-spacing-3xl);
        color: var(--layer-gray-500);
        text-align: center;
      }

      .Friday__empty-state__icon {
        font-size: 3rem;
        margin-bottom: var(--layer-spacing-lg);
        opacity: 0.5;
      }

      .Friday__empty-state__title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--layer-gray-700);
        margin: 0 0 var(--layer-spacing-sm);
      }

      .Friday__empty-state__description {
        font-size: 0.875rem;
        color: var(--layer-gray-500);
        max-width: 24rem;
        line-height: 1.5;
      }

      /* Responsive Design */
      @media (max-width: 768px) {
        .Friday__chart-of-accounts__toolbar {
          flex-direction: column;
          align-items: stretch;
          gap: var(--layer-spacing-md);
        }

        .Friday__toolbar-left,
        .Friday__toolbar-right {
          flex-direction: column;
          align-items: stretch;
        }

        .Friday__search-field {
          width: 100%;
        }

        .Friday__sidebar {
          width: 100%;
        }

        .Friday__table-header .Friday__chart-of-accounts--subtype,
        .Friday__table-header .Friday__chart-of-accounts--type {
          display: none;
        }

        .Friday__table-row .Friday__chart-of-accounts--subtype,
        .Friday__table-row .Friday__chart-of-accounts--type {
          display: none;
        }
      }

      /* Backdrop */
      .Friday__backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
      }

      .Friday__backdrop--visible {
        opacity: 1;
        pointer-events: all;
      }
    `],e([ut({type:Boolean,attribute:"as-widget"})],t.ChartOfAccountsWidget.prototype,"asWidget",void 0),e([ut({type:Boolean,attribute:"with-date-control"})],t.ChartOfAccountsWidget.prototype,"withDateControl",void 0),e([ut({type:Boolean,attribute:"with-expand-all-button"})],t.ChartOfAccountsWidget.prototype,"withExpandAllButton",void 0),e([ut({type:String,attribute:"balance-date"})],t.ChartOfAccountsWidget.prototype,"balanceDate",void 0),e([ut({type:Boolean,attribute:"show-demo"})],t.ChartOfAccountsWidget.prototype,"showDemo",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"accounts",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"filteredAccounts",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"searchQuery",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"selectedAccountType",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"isAllExpanded",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"selectedAccount",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"showAccountForm",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"formMode",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"formData",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"isLoading",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"error",void 0),e([ht()],t.ChartOfAccountsWidget.prototype,"hoveredRowId",void 0),t.ChartOfAccountsWidget=e([(t=>(e,r)=>{void 0!==r?r.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)})("friday-chart-of-accounts-widget")],t.ChartOfAccountsWidget),t}({});