Plugin Directory

Changeset 3361573


Ignore:
Timestamp:
09/15/2025 07:47:05 AM (7 months ago)
Author:
them.es
Message:

updated trunk

Location:
billy
Files:
670 added
3 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • billy/trunk/billy.php

    r3355121 r3361573  
    44 * Plugin URI: https://wordpress.org/plugins/billy
    55 * Description: A business-oriented billing suite powered by WordPress.
    6  * Version: 1.11.1
     6 * Version: 1.12.0
    77 * Author: them.es
    88 * Author URI: https://them.es/plugins/billy
  • billy/trunk/blocks/build/index.asset.php

    r3355121 r3361573  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-server-side-render'), 'version' => '8fa277e056564a026ca5');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-server-side-render'), 'version' => '216e6eebeefb7f42f3cf');
  • billy/trunk/blocks/build/index.js

    r3355121 r3361573  
    1 (()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var s in l)e.o(l,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:l[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,l=window.wp.i18n,s=window.wp.blockEditor,a=window.wp.components,n=window.wp.serverSideRender;var i=e.n(n);const r=window.ReactJSXRuntime;(0,t.registerBlockType)("billy-blocks/header",{title:(0,l.__)("Header","billy"),icon:"editor-table",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:e=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:[(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,r.jsx)("a",{href:globalDataBilly.wpAdmin+"edit.php?post_type=wp_block",children:(0,l.sprintf)((0,l.__)("Edit the %s layout","billy"),(0,l.__)("Header","billy"))})})}),(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Header","billy"))})})]})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/header"})})]}),save:e=>null});const c=window.wp.data;(0,t.registerBlockType)("billy-blocks/invoice-actions",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Actions","billy")),icon:"menu-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)(e=>({postModifiedDate:e("core/editor").getEditedPostAttribute("modified")}))(e=>{const{postModifiedDate:t}=e,a=(0,s.useBlockProps)({className:"components-placeholder",style:{minHeight:"auto"}});return(0,r.jsx)("div",{...a,children:(0,r.jsx)("small",{children:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Last modified","billy"),new Date(t).toLocaleString())})})}),save:()=>null});const o=window.wp.element;(0,t.registerBlockType)("billy-blocks/invoice-meta",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Meta","billy")),icon:"editor-textcolor",category:"billy-blocks",attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},supports:{inserter:!1,reusable:!1,html:!1,className:!0},edit:e=>{const{className:t,attributes:{label:n,text:i},setAttributes:c}=e,d=(0,s.useBlockProps)({className:t?" "+t:""});return(0,r.jsxs)("div",{...d,children:[(0,r.jsxs)(s.InspectorControls,{children:[(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Label","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"label",value:null!=n?n:"",onChange:e=>{c({label:e})}})}),(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Text","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"text",value:null!=i?i:"",onChange:e=>{c({text:e})}})})]}),(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),n||"",i||(0,l.__)("N/A","billy"))})]})},save:e=>{const{className:t,attributes:{label:a,text:n}}=e,i=s.useBlockProps.save({className:t?" "+t:""});return n&&(0,r.jsx)("div",{...i,children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),a||"",n||(0,l.__)("N/A","billy"))})})},deprecated:[{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{className:t,attributes:{label:s,text:a}}=e;return a&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),s||"",a||(0,l.__)("N/A","billy"))})})}},{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{className:t,attributes:{label:s,text:a}}=e;return a&&(0,r.jsx)("p",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)("<p>"+(0,l.__)("<strong>%1$s</strong> <span>%2$s</span>","billy")+"</p>",s||"",a||(0,l.__)("N/A","billy"))})})}}]}),(0,t.registerBlockType)("billy-blocks/invoice-date",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Date","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice is-warning",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("Due to legal requirements in some countries, autogenerated data like %s can't be modified anymore after an invoice has been created in the system!","billy"),(0,l.__)("Date","billy"))})})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-date"})})]})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/invoice-duedate",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Due Date","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Payment due days","billy"))})})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-duedate"})})]})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/invoice-number",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Number","billy")),icon:"editor-ol",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:[(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Invoice number: Prefix","billy"))})}),(0,r.jsx)("div",{className:"components-notice is-warning",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("Due to legal requirements in some countries, autogenerated data like %s can't be modified anymore after an invoice has been created in the system!","billy"),(0,l.__)("Invoice number","billy"))})})]})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-number"})})]})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/invoice-paymentinformation",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Payment Information","billy")),icon:"info",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Payment Information","billy"))})})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-paymentinformation"})})]})},save:()=>null});const d=(e,t=void 0)=>e.toLocaleString(t,{minimumFractionDigits:2,maximumFractionDigits:2}),u=e=>parseFloat(e)/100,b=e=>(e=new Date(e)||new Date,[1,2,3,4][Math.floor(e.getMonth()/3)]),x=[{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"invoicetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"invoicetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"invoicetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}}],p=[{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:a&&a}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:c&&d(c,n)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,n),"<small>("+i+")</small>")})})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:s,locale:a,description:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:s&&s}),(0,r.jsx)("td",{children:n&&(0,r.jsx)(o.RawHTML,{children:n})}),(0,r.jsx)("td",{children:c&&d(c,a)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,a),"<small>("+i+")</small>")})})]})}}];let y;(0,t.registerBlockType)("billy-blocks/invoice-table",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Table","billy")),icon:"menu-alt",category:"billy-blocks",attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlocksByClientId:l}=e("core/block-editor");return{childBlocks:l(t)[0].innerBlocks}})(e=>{const{className:t,childBlocks:n,attributes:{currency:i,locale:c,amountSubtotal:b,amountTotal:x,taxRates:p,taxRatesTotal:h},setAttributes:m}=e,_=(0,s.useBlockProps)({className:"invoicetable-block"+(t?" "+t:"")});return y=()=>{let e=0,t=0,l=0,s=[],a=[];m({currency:globalDataBilly.currency,locale:globalDataBilly.locale}),n&&n.length>0&&(n.forEach(l=>{const a=Number(l.attributes.amount),n=u(l.attributes.taxRate);e+=a,t+=a+n*a,s.push({taxRate:l.attributes.taxRate,amount:n*a})}),s.length>0&&(l=s.reduce((e,t)=>e+t.amount,0),l=Number(l.toFixed(2)),s.reduce((e,t)=>(e[t.taxRate]||(e[t.taxRate]={taxRate:t.taxRate,amount:0},a.push(e[t.taxRate])),e[t.taxRate].amount+=t.amount,e),{})),m({taxRatesTotal:l,taxRates:JSON.stringify(a),amountSubtotal:e,amountTotal:t}))},(0,o.useEffect)(()=>{y()},[n]),(0,r.jsxs)("div",{..._,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Actions","billy"),children:(0,r.jsx)("button",{id:"updatetotals",className:"components-button is-secondary is-button",onClick:y,children:(0,l.__)("Update Totals","billy")})})}),(0,r.jsx)(s.InnerBlocks,{templateLock:!1,template:[["billy-blocks/invoice-tablerow"]],allowedBlocks:["billy-blocks/invoice-tablerow"],renderAppender:()=>(0,r.jsx)(s.InnerBlocks.ButtonBlockAppender,{})}),b>0&&(0,r.jsx)("table",{className:"totals",children:(0,r.jsxs)("tbody",{children:[b>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{style:{width:"50%"},children:x>b?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(b,c))})]}),p&&h>0&&(0,r.jsxs)("tr",{className:"taxRates",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(p).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),i,d(e.amount,c),"<small>("+e.taxRate+")</small><br>")},t)})})]}),x>b&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(x,c))})]})]})})]})}),save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"invoicetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col","data-label":"title"}),(0,r.jsx)("th",{scope:"col","data-label":"description"}),(0,r.jsx)("th",{scope:"col","data-label":"amount"}),b&&x>0&&(0,r.jsx)("th",{scope:"col","data-label":"tax"})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2","data-label":c>i?"subtotal":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"tax"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})},deprecated:x}),(0,t.registerBlockType)("billy-blocks/invoice-tablerow",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Table Row","billy")),icon:"menu-alt",category:"billy-blocks",parent:["billy-blocks/invoice-table"],attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlockRootClientId:l,getBlockIndex:s}=e("core/block-editor");return{i:s(t,l(t))+1}})(e=>{const{i:t,attributes:{index:n,currency:i,locale:c,description:d,taxRate:b,amount:x,amountIncl:p,quantity:h,quantityRate:m},setAttributes:_}=e,j=(0,s.useBlockProps)();(0,o.useEffect)(()=>{_({index:t,currency:globalDataBilly.currency,locale:globalDataBilly.locale}),""===b&&_({taxRate:0===globalDataBilly.taxOptions.length?"0%":globalDataBilly.taxOptions[0].value})},[b]);const f=e=>{_({amountIncl:e>0?Number(e):""}),y()},g=e=>{_({amount:e>0?Number(e):""}),f(Number(e)+Number(e)*u(b))};return(0,r.jsxs)("div",{...j,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Quantity/Rate Calculator","billy"),children:[(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.__)("Quantity","billy"),placeholder:(0,l.__)("0","billy"),value:null!=h?h:"",onChange:e=>{_({quantity:e>0?Number(e):""}),g(Number(e)*Number(m))}}),(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Rate","billy"),i),placeholder:(0,l.__)("0","billy"),value:null!=m?m:"",onChange:e=>{_({quantityRate:e>0?Number(e):""}),g(Number(h)*Number(e))}})]})}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"index",children:n&&n}),(0,r.jsx)("td",{style:{width:"30vw",minWidth:"200px"},children:(0,r.jsx)(s.InnerBlocks,{template:[["core/paragraph",{content:d||""}]],allowedBlocks:["core/block","core/heading","core/paragraph","core/list","core/html"]})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Amount","billy"),i),className:"amount",placeholder:(0,l.__)("0","billy"),value:null!=x?x:"",onChange:g})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.SelectControl,{className:"taxrate",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Tax","billy"),"%"),value:null!=b?b:"",options:0!==globalDataBilly.taxOptions.length?globalDataBilly.taxOptions:"0%"!==b&&0===globalDataBilly.taxOptions.length?[{label:b,value:b},{label:"0%",value:"0%"}]:"",onChange:e=>{_({taxRate:e}),f(Number(x)+Number(x)*u(e))}})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",disabled:"disabled",label:i,className:"amount-tax",placeholder:(0,l.__)("0","billy"),value:null!=p?p:""})})]})})})]})}),save:e=>{const{attributes:{index:t,locale:a,taxRate:n,amount:i}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:t&&t}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:i&&d(i,a)}),n&&u(n)*i>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(n)*i,a),"<small>("+n+")</small>")})})]})},deprecated:p}),(0,t.registerBlockType)("billy-blocks/quote-actions",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Actions","billy")),icon:"menu-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)(e=>({postModifiedDate:e("core/editor").getEditedPostAttribute("modified")}))(e=>{const{postModifiedDate:t}=e,a=(0,s.useBlockProps)({className:"components-placeholder",style:{minHeight:"auto"}});return(0,r.jsx)("div",{...a,children:(0,r.jsx)("small",{children:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Last modified","billy"),new Date(t).toLocaleString())})})}),save:()=>null}),(0,t.registerBlockType)("billy-blocks/quote-meta",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Meta","billy")),icon:"editor-textcolor",category:"billy-blocks",attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},supports:{inserter:!1,reusable:!1,html:!1,className:!0},edit:e=>{const{className:t,attributes:{label:n,text:i},setAttributes:c}=e,d=(0,s.useBlockProps)({className:t?" "+t:""});return(0,r.jsxs)("div",{...d,children:[(0,r.jsxs)(s.InspectorControls,{children:[(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Label","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"label",value:null!=n?n:"",onChange:e=>{c({label:e})}})}),(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Text","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"text",value:null!=i?i:"",onChange:e=>{c({text:e})}})})]}),(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),n||"",i||(0,l.__)("N/A","billy"))})]})},save:e=>{const{className:t,attributes:{label:a,text:n}}=e,i=s.useBlockProps.save({className:t?" "+t:""});return n&&(0,r.jsx)("div",{...i,children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),a||"",n||(0,l.__)("N/A","billy"))})})},deprecated:[{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{attributes:{label:t,text:s}}=e;return s&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),t||"",s||(0,l.__)("N/A","billy"))})})}},{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{attributes:{label:t,text:s}}=e;return s&&(0,r.jsx)("p",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)("<p>"+(0,l.__)("<strong>%1$s</strong> <span>%2$s</span>","billy")+"</p>",t||"",s||(0,l.__)("N/A","billy"))})})}}]}),(0,t.registerBlockType)("billy-blocks/quote-date",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Date","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsx)("div",{...e,children:(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/quote-date"})})})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/quote-information",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Information","billy")),icon:"info",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Quote Information","billy"))})})})}),(0,r.jsx)(i(),{block:"billy-blocks/quote-information"})]})},save:()=>null});const h=[{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"quotetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"quotetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"quotetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}}],m=[{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:a&&a}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:c&&d(c,n)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,n),"<small>("+i+")</small>")})})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:s,locale:a,description:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:s&&s}),(0,r.jsx)("td",{children:n&&(0,r.jsx)(o.RawHTML,{children:n})}),(0,r.jsx)("td",{children:c&&d(c,a)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,a),"<small>("+i+")</small>")})})]})}}];let _;(0,t.registerBlockType)("billy-blocks/quote-table",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Table","billy")),icon:"menu-alt",category:"billy-blocks",attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlocksByClientId:l}=e("core/block-editor");return{childBlocks:l(t)[0].innerBlocks}})(e=>{const{className:t,childBlocks:n,attributes:{currency:i,locale:c,amountSubtotal:b,amountTotal:x,taxRates:p,taxRatesTotal:y},setAttributes:h}=e,m=(0,s.useBlockProps)({className:"quotetable-block"+(t?" "+t:"")});return _=()=>{let e=0,t=0,l=0,s=[],a=[];h({currency:globalDataBilly.currency,locale:globalDataBilly.locale}),n&&n.length>0&&(n.forEach(l=>{const a=Number(l.attributes.amount),n=u(l.attributes.taxRate);e+=a,t+=a+n*a,s.push({taxRate:l.attributes.taxRate,amount:n*a})}),s.length>0&&(l=s.reduce((e,t)=>e+t.amount,0),l=Number(l.toFixed(2)),s.reduce((e,t)=>(e[t.taxRate]||(e[t.taxRate]={taxRate:t.taxRate,amount:0},a.push(e[t.taxRate])),e[t.taxRate].amount+=t.amount,e),{})),h({taxRatesTotal:l,taxRates:JSON.stringify(a),amountSubtotal:e,amountTotal:t}))},(0,o.useEffect)(()=>{_()},[n]),(0,r.jsxs)("div",{...m,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Actions","billy"),children:(0,r.jsx)("button",{id:"updatetotals",className:"components-button is-secondary is-button",onClick:_,children:(0,l.__)("Update Totals","billy")})})}),(0,r.jsx)(s.InnerBlocks,{templateLock:!1,template:[["billy-blocks/quote-tablerow"]],allowedBlocks:["billy-blocks/quote-tablerow"],renderAppender:()=>(0,r.jsx)(s.InnerBlocks.ButtonBlockAppender,{})}),b>0&&(0,r.jsx)("table",{className:"totals",children:(0,r.jsxs)("tbody",{children:[b>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{style:{width:"50%"},children:x>b?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(b,c))})]}),p&&y>0&&(0,r.jsxs)("tr",{className:"taxRates",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(p).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),i,d(e.amount,c),"<small>("+e.taxRate+")</small><br>")},t)})})]}),x>b&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(x,c))})]})]})})]})}),save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"quotetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col","data-label":"title"}),(0,r.jsx)("th",{scope:"col","data-label":"description"}),(0,r.jsx)("th",{scope:"col","data-label":"amount"}),b&&x>0&&(0,r.jsx)("th",{scope:"col","data-label":"tax"})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2","data-label":c>i?"subtotal":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"tax"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})},deprecated:h}),(0,t.registerBlockType)("billy-blocks/quote-tablerow",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Table Row","billy")),icon:"menu-alt",category:"billy-blocks",parent:["billy-blocks/quote-table"],attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlockRootClientId:l,getBlockIndex:s}=e("core/block-editor");return{i:s(t,l(t))+1}})(e=>{const{i:t,attributes:{index:n,currency:i,locale:c,description:d,taxRate:b,amount:x,amountIncl:p,quantity:y,quantityRate:h},setAttributes:m}=e,j=(0,s.useBlockProps)();(0,o.useEffect)(()=>{m({index:t,currency:globalDataBilly.currency,locale:globalDataBilly.locale}),""===b&&m({taxRate:0===globalDataBilly.taxOptions.length?"0%":globalDataBilly.taxOptions[0].value})},[b]);const f=e=>{m({amountIncl:e>0?Number(e):""}),_()},g=e=>{m({amount:e>0?Number(e):""}),f(Number(e)+Number(e)*u(b))};return(0,r.jsxs)("div",{...j,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Quantity/Rate Calculator","billy"),children:[(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.__)("Quantity","billy"),placeholder:(0,l.__)("0","billy"),value:null!=y?y:"",onChange:e=>{m({quantity:e>0?Number(e):""}),g(Number(e)*Number(h))}}),(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Rate","billy"),i),placeholder:(0,l.__)("0","billy"),value:null!=h?h:"",onChange:e=>{m({quantityRate:e>0?Number(e):""}),g(Number(y)*Number(e))}})]})}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"index",children:n&&n}),(0,r.jsx)("td",{style:{width:"30vw",minWidth:"200px"},children:(0,r.jsx)(s.InnerBlocks,{template:[["core/paragraph",{content:d||""}]],allowedBlocks:["core/block","core/heading","core/paragraph","core/list","core/html"]})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Amount","billy"),i),className:"amount",placeholder:(0,l.__)("0","billy"),value:null!=x?x:"",onChange:g})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.SelectControl,{className:"taxrate",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Tax","billy"),"%"),value:null!=b?b:"",options:0!==globalDataBilly.taxOptions.length?globalDataBilly.taxOptions:"0%"!==b&&0===globalDataBilly.taxOptions.length?[{label:b,value:b},{label:"0%",value:"0%"}]:"",onChange:e=>{m({taxRate:e}),f(Number(x)+Number(x)*u(e))}})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",disabled:"disabled",label:i,className:"amount-tax",placeholder:(0,l.__)("0","billy"),value:null!=p?p:""})})]})})})]})}),save:e=>{const{attributes:{index:t,locale:a,taxRate:n,amount:i}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:t&&t}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:i&&d(i,a)}),n&&u(n)*i>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(n)*i,a),"<small>("+n+")</small>")})})]})},deprecated:m}),(0,t.registerBlockType)("billy-blocks/quote-validuntildate",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Valid Until","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsx)("div",{...e,children:(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/quote-validuntildate"})})})},save:()=>null});const j=[{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Taxes","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"5",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"5",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"5",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Taxes","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"5",className:"alignright",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"5",className:"alignright",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"5",className:"alignright",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earning","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expense","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}}],f=[{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,date:i,quarter:c,earning:o,expense:u,tax:b,reference:x,postLink:p}}=e;return(0,r.jsxs)("tr",{"data-date":i&&new Date(i).toISOString().substring(0,10),"data-quarter":c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c),"data-reference":x&&x,"data-earning":o>0?o:null,"data-expense":u>0?u:null,"data-tax":b>0?b:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:a&&a}),(0,r.jsxs)("td",{className:"date","data-value":i&&new Date(i).toISOString().substring(0,10),children:[i&&new Date(i).toISOString().substring(0,10),(0,r.jsx)("sub",{children:c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c)})]}),(0,r.jsx)("td",{className:"description",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("td",{className:"reference",children:[x&&!p&&x,x&&p&&(0,r.jsx)("a",{href:p,children:x})]}),(0,r.jsx)("td",{className:"amount earning","data-value":o>0?o:null,children:o&&o>0&&d(o,n)}),(0,r.jsx)("td",{className:"amount expense","data-value":u>0?u:null,children:u&&u>0&&d(u,n)}),b&&b>0&&(0,r.jsx)("td",{className:"amount tax","data-value":b,children:d(b,n)})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,date:i,quarter:c,earning:o,expense:u,tax:b,reference:x,postLink:p}}=e;return(0,r.jsxs)("tr",{"data-date":i&&new Date(i).toISOString().substring(0,10),"data-quarter":c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c),"data-reference":x&&x,"data-earning":o>0?o:null,"data-expense":u>0?u:null,"data-tax":b>0?b:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:a&&a}),(0,r.jsxs)("td",{className:"date","data-value":i&&new Date(i).toISOString().substring(0,10),children:[i&&new Date(i).toISOString().substring(0,10),(0,r.jsx)("sub",{children:c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c)})]}),(0,r.jsx)("td",{className:"description",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("td",{className:"reference",children:[x&&!p&&x,x&&p&&(0,r.jsx)("a",{href:p,children:x})]}),(0,r.jsx)("td",{className:"amount earning","data-value":o>0?o:null,children:o&&o>0&&d(o,n)}),(0,r.jsx)("td",{className:"amount expense","data-value":u>0?u:null,children:u&&u>0&&d(u,n)}),(0,r.jsx)("td",{className:"amount tax","data-value":b>0?b:null,children:b&&b>0&&d(b,n)})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},description:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},save:e=>{const{className:t,attributes:{index:s,locale:a,date:n,quarter:i,description:c,earning:o,expense:u,tax:b,reference:x,postLink:p}}=e;return(0,r.jsxs)("tr",{"data-date":n&&new Date(n).toISOString().substring(0,10),"data-quarter":i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i),"data-reference":x&&x,"data-earning":o>0?o:null,"data-expense":u>0?u:null,"data-tax":b>0?b:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:s&&s}),(0,r.jsxs)("td",{className:"date","data-value":n&&new Date(n).toISOString().substring(0,10),children:[n&&new Date(n).toISOString().substring(0,10),(0,r.jsx)("sub",{children:i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i)})]}),(0,r.jsx)("td",{className:"description",children:c&&c}),(0,r.jsxs)("td",{className:"reference",children:[x&&!p&&x,x&&p&&(0,r.jsx)("a",{href:p,children:x})]}),(0,r.jsx)("td",{className:"amount earning","data-value":o>0?o:null,children:o&&o>0&&d(o,a)}),(0,r.jsx)("td",{className:"amount expense","data-value":u>0?u:null,children:u&&u>0&&d(u,a)}),(0,r.jsx)("td",{className:"amount tax","data-value":b>0?b:null,children:b&&b>0&&d(b,a)})]})}}];let g;(0,t.registerBlockType)("billy-blocks/accounting-table",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Accounting","billy"),(0,l.__)("Table","billy")),icon:"menu-alt",category:"billy-blocks",attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlocksByClientId:l}=e("core/block-editor"),s=l(t)[0].innerBlocks;return s.sort((e,t)=>new Date(e.attributes.date)-new Date(t.attributes.date)),{childBlocks:s}})(e=>{const{className:t,childBlocks:n,attributes:{currency:i,locale:c,amountTotalEarnings:u,amountTotalExpenses:b,amountTaxEarnings:x,amountTaxExpenses:p},setAttributes:y}=e,h=(0,s.useBlockProps)({className:"accountingtable-block"+(t?" "+t:"")});return g=()=>{let e=0,t=0,l=0,s=0;y({currency:globalDataBilly.currency,locale:globalDataBilly.locale}),n&&n.length>0&&n.forEach(a=>{const n=Number(a.attributes.tax);e+=Number(a.attributes.earning),t+=Number(a.attributes.expense),a.attributes.earning&&(l+=n),a.attributes.expense&&(s+=n)}),y({amountTotalEarnings:e,amountTotalExpenses:t,amountTaxEarnings:l,amountTaxExpenses:s})},(0,o.useEffect)(()=>{g()},[n]),(0,r.jsxs)("div",{...h,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Actions","billy"),children:(0,r.jsx)("button",{id:"updatetotals",className:"components-button is-secondary is-button",onClick:g,children:(0,l.__)("Update Totals","billy")})})}),(0,r.jsx)(s.InnerBlocks,{templateLock:!1,template:[["billy-blocks/accounting-tablerow"]],allowedBlocks:["billy-blocks/accounting-tablerow"],renderAppender:()=>(0,r.jsx)(s.InnerBlocks.ButtonBlockAppender,{})}),(0,r.jsx)("table",{className:"totals",children:(0,r.jsxs)("tbody",{children:[u>0&&(0,r.jsxs)("tr",{className:"earnings",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(u,c))})]}),b>0&&(0,r.jsxs)("tr",{className:"expenses",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(b,c))})]}),(u>0||b>0)&&(0,r.jsxs)("tr",{className:"profit",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{style:{borderTop:"2px solid"},children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(u-b,c))})]}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("tr",{className:"taxes-earnings",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.sprintf)((0,l.__)("Taxes (%s)","billy"),(0,l.__)("Earnings","billy"))}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(x,c))})]}),(0,r.jsxs)("tr",{className:"taxes-expenses",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.sprintf)((0,l.__)("Taxes (%s)","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(p,c))})]})]})]})})]})}),save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e,b=s.useBlockProps.save({className:"alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...b,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(o>0||u>0)&&(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Taxes","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"4",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"4",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"4",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})},deprecated:j}),(0,t.registerBlockType)("billy-blocks/accounting-tablerow",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Accounting","billy"),(0,l.__)("Table Row","billy")),icon:"menu-alt",category:"billy-blocks",parent:["billy-blocks/accounting-table"],attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlockRootClientId:l,getBlockIndex:s}=e("core/block-editor");return{clientId:t,rootClientId:l(t),i:s(t,l(t))+1}})(e=>{const{clientId:t,rootClientId:n,i,attributes:{index:d,currency:u,locale:x,description:p,date:y,quarter:h,earning:m,expense:_,tax:j,reference:f,postUUID:N,postTitle:$,postLink:k,postType:T},setAttributes:v}=e,w=(0,s.useBlockProps)();return(0,o.useEffect)(()=>{v({index:i,currency:globalDataBilly.currency,locale:globalDataBilly.locale}),""===y&&v({date:(new Date).toISOString().substring(0,10),quarter:b((new Date).toISOString().substring(0,10))})},[]),(0,r.jsxs)("div",{...w,children:[(0,r.jsxs)(s.InspectorControls,{children:[!N&&(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Date","billy"),children:(0,r.jsx)(a.DatePicker,{currentDate:y,onChange:e=>{v({date:e}),(e=>{v({quarter:Number(b(e))})})(e),(0,c.dispatch)("core/block-editor").moveBlockToPosition(t,n,n,i)}})}),N&&k&&(0,r.jsx)(a.PanelBody,{title:(0,l.sprintf)((0,l.__)("Reference: %s","billy"),T?T.charAt(0).toUpperCase()+T.substring(1):(0,l.__)("Post","billy")),children:(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:k,children:$||k})})})]}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"index",children:d&&d}),(0,r.jsxs)("td",{className:"date",children:[y&&new Date(y).toISOString().substring(0,10),(0,r.jsx)("sub",{children:h&&(0,l.sprintf)((0,l.__)("Q%s","billy"),h)})]}),(0,r.jsx)("td",{className:"description",style:{minWidth:"200px"},children:(0,r.jsx)(s.InnerBlocks,{template:[["core/paragraph",{content:p||""}]],allowedBlocks:["core/block","core/heading","core/paragraph","core/list","core/html"]})}),(0,r.jsx)("td",{className:"reference",children:(0,r.jsx)(a.TextControl,{type:"text",label:(0,l.__)("Reference","billy"),placeholder:"",value:null!=f?f:"",onChange:e=>{v({reference:e})}})}),(0,r.jsx)("td",{className:"amount earning",children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Earning","billy"),u),placeholder:(0,l.__)("0","billy"),value:null!=m?m:"",onChange:e=>{v({expense:"",earning:e>0?Number(e):""}),g()}})}),(0,r.jsx)("td",{className:"amount expense",children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Expense","billy"),u),placeholder:(0,l.__)("0","billy"),value:null!=_?_:"",onChange:e=>{v({earning:"",expense:e>0?Number(e):""}),g()}})}),(0,r.jsx)("td",{className:"amount tax",children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Tax","billy"),u),placeholder:(0,l.__)("0","billy"),value:null!=j?j:"",onChange:e=>{v({tax:e>0?Number(e):""}),g()}})})]})})})]})}),save:e=>{const{attributes:{index:t,locale:a,date:n,quarter:i,earning:c,expense:o,tax:u,reference:b,postLink:x}}=e;return(0,r.jsxs)("tr",{"data-date":n&&new Date(n).toISOString().substring(0,10),"data-quarter":i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i),"data-reference":b&&b,"data-earning":c>0?c:null,"data-expense":o>0?o:null,"data-tax":u>0?u:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:t&&t}),(0,r.jsxs)("td",{className:"date","data-value":n&&new Date(n).toISOString().substring(0,10),children:[n&&new Date(n).toISOString().substring(0,10),(0,r.jsx)("sub",{children:i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i)})]}),(0,r.jsx)("td",{className:"description",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("td",{className:"reference",children:[b&&!x&&b,b&&x&&(0,r.jsx)("a",{href:x,children:b})]}),(0,r.jsx)("td",{className:"amount earning","data-value":c>0?c:null,children:c&&c>0&&d(c,a)}),(0,r.jsx)("td",{className:"amount expense","data-value":o>0?o:null,children:o&&o>0&&d(o,a)}),u&&u>0&&(0,r.jsx)("td",{className:"amount tax","data-value":u,children:d(u,a)})]})},deprecated:f}),(0,t.registerBlockType)("billy-blocks/accounting-actions",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Accounting","billy"),(0,l.__)("Actions","billy")),icon:"menu-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)(e=>({postModifiedDate:e("core/editor").getEditedPostAttribute("modified")}))(e=>{const{postModifiedDate:t}=e,a=(0,s.useBlockProps)({className:"components-placeholder",style:{minHeight:"auto"}});return(0,r.jsx)("div",{...a,children:(0,r.jsx)("small",{children:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Last modified","billy"),new Date(t).toLocaleString())})})}),save:()=>null});const N=window.wp.plugins,$=window.wp.editor;(0,N.registerPlugin)("billy-setup",{render:()=>(0,r.jsxs)($.PluginDocumentSettingPanel,{name:"billy-setup",title:(0,l.__)("Billy Setup","billy"),className:"my-document-setting-plugin",children:[(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:globalDataBilly.wpAdmin+"customize.php?autofocus[panel]=billy_setup_panel",children:(0,l.__)("Settings (Theme Customizer)","billy")})}),(0,r.jsxs)("ul",{className:"ul code",children:[(0,r.jsx)("li",{title:(0,l.__)("Invoice number","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-number"})}),(0,r.jsx)("li",{title:(0,l.__)("Quote number","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/quote-number"})}),(0,r.jsx)("li",{title:(0,l.__)("Name","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"name"}})}),(0,r.jsx)("li",{title:(0,l.__)("Address","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"address"}})}),(0,r.jsx)("li",{title:(0,l.__)("VAT","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"vat"}})}),(0,r.jsx)("li",{title:(0,l.__)("Currency","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"currency"}})}),(0,r.jsx)("li",{title:(0,l.__)("Taxes","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"taxrates"}})})]})]})}),(0,t.registerBlockType)("billy-blocks/theme-mod",{apiVersion:2,title:(0,l.__)("Theme Mod","billy"),icon:"admin-generic",category:"billy-blocks",attributes:{themeMod:{type:"string",default:""}},supports:{inserter:!1,reusable:!1,html:!1},edit:e=>{const{attributes:{themeMod:t},setAttributes:n}=e,c=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...c,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Theme Mod","billy"),children:(0,r.jsx)(a.SelectControl,{label:(0,l.__)("Setting","billy"),help:(0,l.__)("Modify the value in the Theme Customizer.","billy"),options:globalDataBilly.themeModOptions,value:null!=t?t:"",onChange:e=>{n({themeMod:e})}})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:e.attributes})})]})},save:()=>null})})();
     1(()=>{"use strict";var e={n:t=>{var l=t&&t.__esModule?()=>t.default:()=>t;return e.d(l,{a:l}),l},d:(t,l)=>{for(var s in l)e.o(l,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:l[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,l=window.wp.i18n,s=window.wp.blockEditor,a=window.wp.components,n=window.wp.serverSideRender;var i=e.n(n);const r=window.ReactJSXRuntime;(0,t.registerBlockType)("billy-blocks/header",{title:(0,l.__)("Header","billy"),icon:"editor-table",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:()=>(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:[(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,r.jsx)("a",{href:globalDataBilly.wpAdmin+"edit.php?post_type=wp_block",children:(0,l.sprintf)((0,l.__)("Edit the %s layout","billy"),(0,l.__)("Header","billy"))})})}),(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Header","billy"))})})]})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/header"})})]}),save:()=>null});const c=window.wp.data;(0,t.registerBlockType)("billy-blocks/invoice-actions",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Actions","billy")),icon:"menu-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)(e=>({postModifiedDate:e("core/editor").getEditedPostAttribute("modified")}))(e=>{const{postModifiedDate:t}=e,a=(0,s.useBlockProps)({className:"components-placeholder",style:{minHeight:"auto"}});return(0,r.jsx)("div",{...a,children:(0,r.jsx)("small",{children:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Last modified","billy"),new Date(t).toLocaleString())})})}),save:()=>null});const o=window.wp.element;(0,t.registerBlockType)("billy-blocks/invoice-meta",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Meta","billy")),icon:"editor-textcolor",category:"billy-blocks",attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},supports:{inserter:!1,reusable:!1,html:!1,className:!0},edit:e=>{const{className:t,attributes:{label:n,text:i},setAttributes:c}=e,d=(0,s.useBlockProps)({className:t?" "+t:""});return(0,r.jsxs)("div",{...d,children:[(0,r.jsxs)(s.InspectorControls,{children:[(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Label","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"label",value:null!=n?n:"",onChange:e=>{c({label:e})}})}),(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Text","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"text",value:null!=i?i:"",onChange:e=>{c({text:e})}})})]}),(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),n||"",i||(0,l.__)("N/A","billy"))})]})},save:e=>{const{className:t,attributes:{label:a,text:n}}=e,i=s.useBlockProps.save({className:t?" "+t:""});return n&&(0,r.jsx)("div",{...i,children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),a||"",n||(0,l.__)("N/A","billy"))})})},deprecated:[{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{className:t,attributes:{label:s,text:a}}=e;return a&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),s||"",a||(0,l.__)("N/A","billy"))})})}},{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{className:t,attributes:{label:s,text:a}}=e;return a&&(0,r.jsx)("p",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)("<p>"+(0,l.__)("<strong>%1$s</strong> <span>%2$s</span>","billy")+"</p>",s||"",a||(0,l.__)("N/A","billy"))})})}}]}),(0,t.registerBlockType)("billy-blocks/invoice-date",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Date","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice is-warning",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("Due to legal requirements in some countries, autogenerated data like %s can't be modified anymore after an invoice has been created in the system!","billy"),(0,l.__)("Date","billy"))})})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-date"})})]})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/invoice-duedate",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Due Date","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Payment due days","billy"))})})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-duedate"})})]})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/invoice-number",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Number","billy")),icon:"editor-ol",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:[(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Invoice number: Prefix","billy"))})}),(0,r.jsx)("div",{className:"components-notice is-warning",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("Due to legal requirements in some countries, autogenerated data like %s can't be modified anymore after an invoice has been created in the system!","billy"),(0,l.__)("Invoice number","billy"))})})]})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-number"})})]})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/invoice-paymentinformation",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Payment Information","billy")),icon:"info",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Payment Information","billy"))})})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-paymentinformation"})})]})},save:()=>null});const d=(e,t=void 0)=>e.toLocaleString(t,{minimumFractionDigits:2,maximumFractionDigits:2}),u=e=>parseFloat(e)/100,b=e=>{const t=new Date(e)||new Date;return[1,2,3,4][Math.floor(t.getMonth()/3)]},x=[{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"invoicetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"invoicetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"invoicetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}}],p=[{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:a&&a}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:c&&d(c,n)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,n),"<small>("+i+")</small>")})})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:s,locale:a,description:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:s&&s}),(0,r.jsx)("td",{children:n&&(0,r.jsx)(o.RawHTML,{children:n})}),(0,r.jsx)("td",{children:c&&d(c,a)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,a),"<small>("+i+")</small>")})})]})}}];let y;(0,t.registerBlockType)("billy-blocks/invoice-table",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Table","billy")),icon:"menu-alt",category:"billy-blocks",attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlocksByClientId:l}=e("core/block-editor");return{childBlocks:l(t)[0].innerBlocks}})(e=>{const{className:t,childBlocks:n,attributes:{currency:i,locale:c,amountSubtotal:b,amountTotal:x,taxRates:p,taxRatesTotal:h},setAttributes:m}=e,_=(0,s.useBlockProps)({className:"invoicetable-block"+(t?" "+t:"")});return y=()=>{let e=0,t=0,l=0,s=[],a=[];m({currency:globalDataBilly.currency,locale:globalDataBilly.locale}),n&&n.length>0&&(n.forEach(l=>{const a=Number(l.attributes.amount),n=u(l.attributes.taxRate);e+=a,t+=a+n*a,s.push({taxRate:l.attributes.taxRate,amount:n*a})}),s.length>0&&(l=s.reduce((e,t)=>e+t.amount,0),l=Number(l.toFixed(2)),s.reduce((e,t)=>(e[t.taxRate]||(e[t.taxRate]={taxRate:t.taxRate,amount:0},a.push(e[t.taxRate])),e[t.taxRate].amount+=t.amount,e),{})),m({taxRatesTotal:l,taxRates:JSON.stringify(a),amountSubtotal:e,amountTotal:t}))},(0,o.useEffect)(()=>{y()},[n]),(0,r.jsxs)("div",{..._,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Actions","billy"),children:(0,r.jsx)("button",{id:"updatetotals",className:"components-button is-secondary is-button",onClick:y,children:(0,l.__)("Update Totals","billy")})})}),(0,r.jsx)(s.InnerBlocks,{templateLock:!1,template:[["billy-blocks/invoice-tablerow"]],allowedBlocks:["billy-blocks/invoice-tablerow"],renderAppender:()=>(0,r.jsx)(s.InnerBlocks.ButtonBlockAppender,{})}),b>0&&(0,r.jsx)("table",{className:"totals",children:(0,r.jsxs)("tbody",{children:[b>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{style:{width:"50%"},children:x>b?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(b,c))})]}),p&&h>0&&(0,r.jsxs)("tr",{className:"taxRates",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(p).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),i,d(e.amount,c),"<small>("+e.taxRate+")</small><br>")},t)})})]}),x>b&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(x,c))})]})]})})]})}),save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"invoicetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col","data-label":"title"}),(0,r.jsx)("th",{scope:"col","data-label":"description"}),(0,r.jsx)("th",{scope:"col","data-label":"amount"}),b&&x>0&&(0,r.jsx)("th",{scope:"col","data-label":"tax"})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2","data-label":c>i?"subtotal":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"tax"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})},deprecated:x}),(0,t.registerBlockType)("billy-blocks/invoice-tablerow",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Invoice","billy"),(0,l.__)("Table Row","billy")),icon:"menu-alt",category:"billy-blocks",parent:["billy-blocks/invoice-table"],attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlockRootClientId:l,getBlockIndex:s}=e("core/block-editor");return{i:s(t,l(t))+1}})(e=>{const{i:t,attributes:{index:n,currency:i,locale:c,description:d,taxRate:b,amount:x,amountIncl:p,quantity:h,quantityRate:m},setAttributes:_}=e,j=(0,s.useBlockProps)();(0,o.useEffect)(()=>{_({index:t,currency:globalDataBilly.currency,locale:globalDataBilly.locale}),""===b&&_({taxRate:0===globalDataBilly.taxOptions.length?"0%":globalDataBilly.taxOptions[0].value})},[b]);const f=e=>{_({amountIncl:e>0?Number(e):""}),y()},g=e=>{_({amount:e>0?Number(e):""}),f(Number(e)+Number(e)*u(b))};return(0,r.jsxs)("div",{...j,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Quantity/Rate Calculator","billy"),children:[(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.__)("Quantity","billy"),placeholder:(0,l.__)("0","billy"),value:null!=h?h:"",onChange:e=>{_({quantity:e>0?Number(e):""}),g(Number(e)*Number(m))}}),(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Rate","billy"),i),placeholder:(0,l.__)("0","billy"),value:null!=m?m:"",onChange:e=>{_({quantityRate:e>0?Number(e):""}),g(Number(h)*Number(e))}})]})}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"index",children:n&&n}),(0,r.jsx)("td",{style:{width:"30vw",minWidth:"200px"},children:(0,r.jsx)(s.InnerBlocks,{template:[["core/paragraph",{content:d||""}]],allowedBlocks:["core/block","core/heading","core/paragraph","core/list","core/html"]})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Amount","billy"),i),className:"amount",placeholder:(0,l.__)("0","billy"),value:null!=x?x:"",onChange:g})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.SelectControl,{className:"taxrate",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Tax","billy"),"%"),value:null!=b?b:"",options:0!==globalDataBilly.taxOptions.length?globalDataBilly.taxOptions:"0%"!==b&&0===globalDataBilly.taxOptions.length?[{label:b,value:b},{label:"0%",value:"0%"}]:"",onChange:e=>{_({taxRate:e}),f(Number(x)+Number(x)*u(e))}})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",disabled:"disabled",label:i,className:"amount-tax",placeholder:(0,l.__)("0","billy"),value:null!=p?p:""})})]})})})]})}),save:e=>{const{attributes:{index:t,locale:a,taxRate:n,amount:i}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:t&&t}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:i&&d(i,a)}),n&&u(n)*i>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(n)*i,a),"<small>("+n+")</small>")})})]})},deprecated:p}),(0,t.registerBlockType)("billy-blocks/quote-actions",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Actions","billy")),icon:"menu-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)(e=>({postModifiedDate:e("core/editor").getEditedPostAttribute("modified")}))(e=>{const{postModifiedDate:t}=e,a=(0,s.useBlockProps)({className:"components-placeholder",style:{minHeight:"auto"}});return(0,r.jsx)("div",{...a,children:(0,r.jsx)("small",{children:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Last modified","billy"),new Date(t).toLocaleString())})})}),save:()=>null}),(0,t.registerBlockType)("billy-blocks/quote-meta",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Meta","billy")),icon:"editor-textcolor",category:"billy-blocks",attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},supports:{inserter:!1,reusable:!1,html:!1,className:!0},edit:e=>{const{className:t,attributes:{label:n,text:i},setAttributes:c}=e,d=(0,s.useBlockProps)({className:t?" "+t:""});return(0,r.jsxs)("div",{...d,children:[(0,r.jsxs)(s.InspectorControls,{children:[(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Label","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"label",value:null!=n?n:"",onChange:e=>{c({label:e})}})}),(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Text","billy"),children:(0,r.jsx)(a.TextControl,{type:"text",className:"text",value:null!=i?i:"",onChange:e=>{c({text:e})}})})]}),(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),n||"",i||(0,l.__)("N/A","billy"))})]})},save:e=>{const{className:t,attributes:{label:a,text:n}}=e,i=s.useBlockProps.save({className:t?" "+t:""});return n&&(0,r.jsx)("div",{...i,children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),a||"",n||(0,l.__)("N/A","billy"))})})},deprecated:[{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{attributes:{label:t,text:s}}=e;return s&&(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)('<div class="label">%1$s</div> <div class="text">%2$s</div>',"billy"),t||"",s||(0,l.__)("N/A","billy"))})})}},{attributes:{label:{type:"string",default:""},text:{type:"string",default:""}},save:e=>{const{attributes:{label:t,text:s}}=e;return s&&(0,r.jsx)("p",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)("<p>"+(0,l.__)("<strong>%1$s</strong> <span>%2$s</span>","billy")+"</p>",t||"",s||(0,l.__)("N/A","billy"))})})}}]}),(0,t.registerBlockType)("billy-blocks/quote-date",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Date","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsx)("div",{...e,children:(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/quote-date"})})})},save:()=>null}),(0,t.registerBlockType)("billy-blocks/quote-information",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Information","billy")),icon:"info",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...e,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Info","billy"),children:(0,r.jsx)("div",{className:"components-notice",children:(0,r.jsx)("div",{className:"components-notice__content",children:(0,l.sprintf)((0,l.__)("The %s values can be modified in the Theme Customizer.","billy"),(0,l.__)("Quote Information","billy"))})})})}),(0,r.jsx)(i(),{block:"billy-blocks/quote-information"})]})},save:()=>null});const h=[{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"quotetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"quotetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",className:"align-right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e;return(0,r.jsx)("div",{className:"quotetable-block alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Amount","billy")}),b&&x>0&&(0,r.jsx)("th",{scope:"col",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:c>i?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("td",{colSpan:"2",align:"right",children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})}}],m=[{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:a&&a}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:c&&d(c,n)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,n),"<small>("+i+")</small>")})})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},description:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},save:e=>{const{className:t,attributes:{index:s,locale:a,description:n,taxRate:i,amount:c}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:s&&s}),(0,r.jsx)("td",{children:n&&(0,r.jsx)(o.RawHTML,{children:n})}),(0,r.jsx)("td",{children:c&&d(c,a)}),i&&u(i)*c>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(i)*c,a),"<small>("+i+")</small>")})})]})}}];let _;(0,t.registerBlockType)("billy-blocks/quote-table",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Table","billy")),icon:"menu-alt",category:"billy-blocks",attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountSubtotal:{type:"number",default:""},amountTotal:{type:"number",default:""},taxRates:{type:"string",default:""},taxRatesTotal:{type:"number",default:""}},supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlocksByClientId:l}=e("core/block-editor");return{childBlocks:l(t)[0].innerBlocks}})(e=>{const{className:t,childBlocks:n,attributes:{currency:i,locale:c,amountSubtotal:b,amountTotal:x,taxRates:p,taxRatesTotal:y},setAttributes:h}=e,m=(0,s.useBlockProps)({className:"quotetable-block"+(t?" "+t:"")});return _=()=>{let e=0,t=0,l=0;const s=[],a=[];h({currency:globalDataBilly.currency,locale:globalDataBilly.locale}),n?.length&&(n.forEach(l=>{const a=Number(l.attributes.amount)||0,n=u(l.attributes.taxRate);e+=a,t+=a+n*a,s.push({taxRate:l.attributes.taxRate,amount:n*a})}),s.length&&(l=s.reduce((e,{amount:t})=>e+t,0),l=Number(l.toFixed(2)),s.forEach(({taxRate:e,amount:t})=>{const l=a.find(t=>t.taxRate===e);l?l.amount+=t:a.push({taxRate:e,amount:t})})),h({taxRatesTotal:l,taxRates:JSON.stringify(a),amountSubtotal:e,amountTotal:t}))},(0,o.useEffect)(()=>{_()},[n]),(0,r.jsxs)("div",{...m,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Actions","billy"),children:(0,r.jsx)("button",{id:"updatetotals",className:"components-button is-secondary is-button",onClick:_,children:(0,l.__)("Update Totals","billy")})})}),(0,r.jsx)(s.InnerBlocks,{templateLock:!1,template:[["billy-blocks/quote-tablerow"]],allowedBlocks:["billy-blocks/quote-tablerow"],renderAppender:()=>(0,r.jsx)(s.InnerBlocks.ButtonBlockAppender,{})}),b>0&&(0,r.jsx)("table",{className:"totals",children:(0,r.jsxs)("tbody",{children:[b>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{style:{width:"50%"},children:x>b?(0,l.__)("Subtotal","billy"):(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(b,c))})]}),p&&y>0&&(0,r.jsxs)("tr",{className:"taxRates",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Tax","billy")}),(0,r.jsx)("td",{children:JSON.parse(p).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),i,d(e.amount,c),"<small>("+e.taxRate+")</small><br>")},t)})})]}),x>b&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Total","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(x,c))})]})]})})]})}),save:e=>{const{className:t,attributes:{currency:a,locale:n,amountSubtotal:i,amountTotal:c,taxRates:b,taxRatesTotal:x}}=e,p=s.useBlockProps.save({className:"quotetable-block alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...p,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col","data-label":"title"}),(0,r.jsx)("th",{scope:"col","data-label":"description"}),(0,r.jsx)("th",{scope:"col","data-label":"amount"}),b&&x>0&&(0,r.jsx)("th",{scope:"col","data-label":"tax"})]})}),(0,r.jsx)("tbody",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[i>0&&(0,r.jsxs)("tr",{className:"subtotal",children:[(0,r.jsx)("th",{colSpan:"2","data-label":c>i?"subtotal":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))})]}),b&&x>0&&(0,r.jsxs)("tr",{className:"taxrates",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"tax"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:JSON.parse(b).sort((e,t)=>u(e.taxRate)-u(t.taxRate)).map((e,t)=>{if(e.amount>0)return(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s %3$s","billy"),a,d(e.amount,n),"<small>("+e.taxRate+")</small><br>")},t)})})]}),c>i&&(0,r.jsxs)("tr",{className:"total",children:[(0,r.jsx)("th",{colSpan:"2","data-label":"total"}),(0,r.jsx)("td",{colSpan:b&&x>0?"2":null,children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]})]})]})})},deprecated:h}),(0,t.registerBlockType)("billy-blocks/quote-tablerow",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Table Row","billy")),icon:"menu-alt",category:"billy-blocks",parent:["billy-blocks/quote-table"],attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},taxRate:{type:"string",default:""},amount:{type:"number",default:""},amountIncl:{type:"number",default:""},quantity:{type:"number",default:""},quantityRate:{type:"number",default:""}},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlockRootClientId:l,getBlockIndex:s}=e("core/block-editor");return{i:s(t,l(t))+1}})(e=>{const{i:t,attributes:{index:n,currency:i,locale:c,description:d,taxRate:b,amount:x,amountIncl:p,quantity:y,quantityRate:h},setAttributes:m}=e,j=(0,s.useBlockProps)();(0,o.useEffect)(()=>{m({index:t,currency:globalDataBilly.currency,locale:globalDataBilly.locale}),""===b&&m({taxRate:0===globalDataBilly.taxOptions.length?"0%":globalDataBilly.taxOptions[0].value})},[b]);const f=e=>{m({amountIncl:e>0?Number(e):""}),_()},g=e=>{m({amount:e>0?Number(e):""}),f(Number(e)+Number(e)*u(b))};return(0,r.jsxs)("div",{...j,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsxs)(a.PanelBody,{title:(0,l.__)("Quantity/Rate Calculator","billy"),children:[(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.__)("Quantity","billy"),placeholder:(0,l.__)("0","billy"),value:null!=y?y:"",onChange:e=>{m({quantity:e>0?Number(e):""}),g(Number(e)*Number(h))}}),(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Rate","billy"),i),placeholder:(0,l.__)("0","billy"),value:null!=h?h:"",onChange:e=>{m({quantityRate:e>0?Number(e):""}),g(Number(y)*Number(e))}})]})}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"index",children:n&&n}),(0,r.jsx)("td",{style:{width:"30vw",minWidth:"200px"},children:(0,r.jsx)(s.InnerBlocks,{template:[["core/paragraph",{content:d||""}]],allowedBlocks:["core/block","core/heading","core/paragraph","core/list","core/html"]})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Amount","billy"),i),className:"amount",placeholder:(0,l.__)("0","billy"),value:null!=x?x:"",onChange:g})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.SelectControl,{className:"taxrate",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Tax","billy"),"%"),value:null!=b?b:"",options:0!==globalDataBilly.taxOptions.length?globalDataBilly.taxOptions:"0%"!==b&&0===globalDataBilly.taxOptions.length?[{label:b,value:b},{label:"0%",value:"0%"}]:"",onChange:e=>{m({taxRate:e}),f(Number(x)+Number(x)*u(e))}})}),(0,r.jsx)("td",{children:(0,r.jsx)(a.TextControl,{type:"number",disabled:"disabled",label:i,className:"amount-tax",placeholder:(0,l.__)("0","billy"),value:null!=p?p:""})})]})})})]})}),save:e=>{const{attributes:{index:t,locale:a,taxRate:n,amount:i}}=e;return(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"row",children:t&&t}),(0,r.jsx)("td",{children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsx)("td",{children:i&&d(i,a)}),n&&u(n)*i>0&&(0,r.jsx)("td",{children:(0,r.jsx)(o.RawHTML,{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),d(u(n)*i,a),"<small>("+n+")</small>")})})]})},deprecated:m}),(0,t.registerBlockType)("billy-blocks/quote-validuntildate",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Quote","billy"),(0,l.__)("Valid Until","billy")),icon:"calendar-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},edit:()=>{const e=(0,s.useBlockProps)();return(0,r.jsx)("div",{...e,children:(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/quote-validuntildate"})})})},save:()=>null});const j=[{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Taxes","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"5",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"5",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"5",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Taxes","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"5",className:"alignright",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"5",className:"alignright",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"5",className:"alignright",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}},{attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e;return(0,r.jsx)("div",{className:"alignwide"+(t?" "+t:""),children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earning","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expense","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Tax","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("td",{colSpan:"4",align:"right",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})}}],f=[{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,date:i,quarter:c,earning:o,expense:u,tax:b,reference:x,postLink:p}}=e;return(0,r.jsxs)("tr",{"data-date":i&&new Date(i).toISOString().substring(0,10),"data-quarter":c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c),"data-reference":x&&x,"data-earning":o>0?o:null,"data-expense":u>0?u:null,"data-tax":b>0?b:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:a&&a}),(0,r.jsxs)("td",{className:"date","data-value":i&&new Date(i).toISOString().substring(0,10),children:[i&&new Date(i).toISOString().substring(0,10),(0,r.jsx)("sub",{children:c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c)})]}),(0,r.jsx)("td",{className:"description",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("td",{className:"reference",children:[x&&!p&&x,x&&p&&(0,r.jsx)("a",{href:p,children:x})]}),(0,r.jsx)("td",{className:"amount earning","data-value":o>0?o:null,children:o&&o>0&&d(o,n)}),(0,r.jsx)("td",{className:"amount expense","data-value":u>0?u:null,children:u&&u>0&&d(u,n)}),b&&b>0&&(0,r.jsx)("td",{className:"amount tax","data-value":b,children:d(b,n)})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},save:e=>{const{className:t,attributes:{index:a,locale:n,date:i,quarter:c,earning:o,expense:u,tax:b,reference:x,postLink:p}}=e;return(0,r.jsxs)("tr",{"data-date":i&&new Date(i).toISOString().substring(0,10),"data-quarter":c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c),"data-reference":x&&x,"data-earning":o>0?o:null,"data-expense":u>0?u:null,"data-tax":b>0?b:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:a&&a}),(0,r.jsxs)("td",{className:"date","data-value":i&&new Date(i).toISOString().substring(0,10),children:[i&&new Date(i).toISOString().substring(0,10),(0,r.jsx)("sub",{children:c&&(0,l.sprintf)((0,l.__)("Q%s","billy"),c)})]}),(0,r.jsx)("td",{className:"description",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("td",{className:"reference",children:[x&&!p&&x,x&&p&&(0,r.jsx)("a",{href:p,children:x})]}),(0,r.jsx)("td",{className:"amount earning","data-value":o>0?o:null,children:o&&o>0&&d(o,n)}),(0,r.jsx)("td",{className:"amount expense","data-value":u>0?u:null,children:u&&u>0&&d(u,n)}),(0,r.jsx)("td",{className:"amount tax","data-value":b>0?b:null,children:b&&b>0&&d(b,n)})]})}},{attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},description:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},save:e=>{const{className:t,attributes:{index:s,locale:a,date:n,quarter:i,description:c,earning:o,expense:u,tax:b,reference:x,postLink:p}}=e;return(0,r.jsxs)("tr",{"data-date":n&&new Date(n).toISOString().substring(0,10),"data-quarter":i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i),"data-reference":x&&x,"data-earning":o>0?o:null,"data-expense":u>0?u:null,"data-tax":b>0?b:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:s&&s}),(0,r.jsxs)("td",{className:"date","data-value":n&&new Date(n).toISOString().substring(0,10),children:[n&&new Date(n).toISOString().substring(0,10),(0,r.jsx)("sub",{children:i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i)})]}),(0,r.jsx)("td",{className:"description",children:c&&c}),(0,r.jsxs)("td",{className:"reference",children:[x&&!p&&x,x&&p&&(0,r.jsx)("a",{href:p,children:x})]}),(0,r.jsx)("td",{className:"amount earning","data-value":o>0?o:null,children:o&&o>0&&d(o,a)}),(0,r.jsx)("td",{className:"amount expense","data-value":u>0?u:null,children:u&&u>0&&d(u,a)}),(0,r.jsx)("td",{className:"amount tax","data-value":b>0?b:null,children:b&&b>0&&d(b,a)})]})}}];let g;(0,t.registerBlockType)("billy-blocks/accounting-table",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Accounting","billy"),(0,l.__)("Table","billy")),icon:"menu-alt",category:"billy-blocks",attributes:{currency:{type:"string",default:""},locale:{type:"string",default:""},amountTotalEarnings:{type:"number",default:""},amountTotalExpenses:{type:"number",default:""},amountTaxEarnings:{type:"number",default:""},amountTaxExpenses:{type:"number",default:""}},supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlocksByClientId:l}=e("core/block-editor"),s=l(t)[0].innerBlocks;return s.sort((e,t)=>new Date(e.attributes.date)-new Date(t.attributes.date)),{childBlocks:s}})(e=>{const{className:t,childBlocks:n,attributes:{currency:i,locale:c,amountTotalEarnings:u,amountTotalExpenses:b,amountTaxEarnings:x,amountTaxExpenses:p},setAttributes:y}=e,h=(0,s.useBlockProps)({className:"accountingtable-block"+(t?" "+t:"")});return g=()=>{let e=0,t=0,l=0,s=0;y({currency:globalDataBilly.currency,locale:globalDataBilly.locale}),n?.length&&n.forEach(a=>{const n=Number(a.attributes.tax)||0,i=Number(a.attributes.earning)||0,r=Number(a.attributes.expense)||0;e+=i,t+=r,i&&(l+=n),r&&(s+=n)}),y({amountTotalEarnings:e,amountTotalExpenses:t,amountTaxEarnings:l,amountTaxExpenses:s})},(0,o.useEffect)(()=>{g()},[n]),(0,r.jsxs)("div",{...h,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Actions","billy"),children:(0,r.jsx)("button",{id:"updatetotals",className:"components-button is-secondary is-button",onClick:g,children:(0,l.__)("Update Totals","billy")})})}),(0,r.jsx)(s.InnerBlocks,{templateLock:!1,template:[["billy-blocks/accounting-tablerow"]],allowedBlocks:["billy-blocks/accounting-tablerow"],renderAppender:()=>(0,r.jsx)(s.InnerBlocks.ButtonBlockAppender,{})}),(0,r.jsx)("table",{className:"totals",children:(0,r.jsxs)("tbody",{children:[u>0&&(0,r.jsxs)("tr",{className:"earnings",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(u,c))})]}),b>0&&(0,r.jsxs)("tr",{className:"expenses",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Expenses","billy")}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(b,c))})]}),(u>0||b>0)&&(0,r.jsxs)("tr",{className:"profit",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{style:{borderTop:"2px solid"},children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(u-b,c))})]}),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("tr",{className:"taxes-earnings",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.sprintf)((0,l.__)("Taxes (%s)","billy"),(0,l.__)("Earnings","billy"))}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(x,c))})]}),(0,r.jsxs)("tr",{className:"taxes-expenses",children:[(0,r.jsx)("th",{style:{width:"50%"},children:(0,l.sprintf)((0,l.__)("Taxes (%s)","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),i,d(p,c))})]})]})]})})]})}),save:e=>{const{className:t,attributes:{currency:a,locale:n,amountTotalEarnings:i,amountTotalExpenses:c,amountTaxEarnings:o,amountTaxExpenses:u}}=e,b=s.useBlockProps.save({className:"alignwide"+(t?" "+t:"")});return(0,r.jsx)("div",{...b,children:(0,r.jsxs)("table",{className:"table wp-block-table",children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"index",children:(0,l.__)("#","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"date",children:(0,l.__)("Date","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"description",children:(0,l.__)("Description","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"reference",children:(0,l.__)("Reference","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort earnings","data-sort":"earning",children:(0,l.__)("Earnings","billy")}),(0,r.jsx)("th",{scope:"col",className:"sort expenses","data-sort":"expense",children:(0,l.__)("Expenses","billy")}),(o>0||u>0)&&(0,r.jsx)("th",{scope:"col",className:"sort","data-sort":"tax",children:(0,l.__)("Taxes","billy")})]})}),(0,r.jsx)("tbody",{className:"list",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("tfoot",{children:[(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"4",children:(0,l.sprintf)((0,l.__)("%1$s / %2$s","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i,n))}),(0,r.jsx)("td",{className:"sum expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(c,n))})]}),(i>0||c>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"4",children:(0,l.__)("Profit","billy")}),(0,r.jsx)("td",{colSpan:"2",className:"profit",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(i-c,n))})]}),(o>0||u>0)&&(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{colSpan:"4",children:(0,l.sprintf)((0,l.__)("%1$s (%2$s / %3$s)","billy"),(0,l.__)("Taxes","billy"),(0,l.__)("Earnings","billy"),(0,l.__)("Expenses","billy"))}),(0,r.jsx)("td",{className:"sum tax-earnings",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(o,n))}),(0,r.jsx)("td",{className:"sum tax-expenses",children:(0,l.sprintf)((0,l.__)("%1$s %2$s","billy"),a,d(u,n))})]})]})]})})},deprecated:j}),(0,t.registerBlockType)("billy-blocks/accounting-tablerow",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Accounting","billy"),(0,l.__)("Table Row","billy")),icon:"menu-alt",category:"billy-blocks",parent:["billy-blocks/accounting-table"],attributes:{index:{type:"number",default:"0"},currency:{type:"string",default:""},locale:{type:"string",default:""},date:{type:"string",default:""},quarter:{type:"number",default:""},reference:{type:"string",default:""},earning:{type:"number",default:""},expense:{type:"number",default:""},tax:{type:"number",default:""},postUUID:{type:"string",default:""},postTitle:{type:"string",default:""},postLink:{type:"string",default:""},postType:{type:"string",default:""}},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)((e,{clientId:t})=>{const{getBlockRootClientId:l,getBlockIndex:s}=e("core/block-editor");return{clientId:t,rootClientId:l(t),i:s(t,l(t))+1}})(e=>{const{clientId:t,rootClientId:n,i,attributes:{index:d,currency:u,locale:x,description:p,date:y,quarter:h,earning:m,expense:_,tax:j,reference:f,postUUID:N,postTitle:$,postLink:k,postType:T},setAttributes:v}=e,w=(0,s.useBlockProps)();return(0,o.useEffect)(()=>{v({index:i,currency:globalDataBilly.currency,locale:globalDataBilly.locale}),""===y&&v({date:(new Date).toISOString().substring(0,10),quarter:b((new Date).toISOString().substring(0,10))})},[]),(0,r.jsxs)("div",{...w,children:[(0,r.jsxs)(s.InspectorControls,{children:[!N&&(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Date","billy"),children:(0,r.jsx)(a.DatePicker,{currentDate:y,onChange:e=>{v({date:e}),(e=>{v({quarter:Number(b(e))})})(e),(0,c.dispatch)("core/block-editor").moveBlockToPosition(t,n,n,i)}})}),N&&k&&(0,r.jsx)(a.PanelBody,{title:(0,l.sprintf)((0,l.__)("Reference: %s","billy"),T?T.charAt(0).toUpperCase()+T.substring(1):(0,l.__)("Post","billy")),children:(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:k,children:$||k})})})]}),(0,r.jsx)("table",{children:(0,r.jsx)("tbody",{children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"index",children:d&&d}),(0,r.jsxs)("td",{className:"date",children:[y&&new Date(y).toISOString().substring(0,10),(0,r.jsx)("sub",{children:h&&(0,l.sprintf)((0,l.__)("Q%s","billy"),h)})]}),(0,r.jsx)("td",{className:"description",style:{minWidth:"200px"},children:(0,r.jsx)(s.InnerBlocks,{template:[["core/paragraph",{content:p||""}]],allowedBlocks:["core/block","core/heading","core/paragraph","core/list","core/html"]})}),(0,r.jsx)("td",{className:"reference",children:(0,r.jsx)(a.TextControl,{type:"text",label:(0,l.__)("Reference","billy"),placeholder:"",value:null!=f?f:"",onChange:e=>{v({reference:e})}})}),(0,r.jsx)("td",{className:"amount earning",children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Earning","billy"),u),placeholder:(0,l.__)("0","billy"),value:null!=m?m:"",onChange:e=>{v({expense:"",earning:e>0?Number(e):""}),g()}})}),(0,r.jsx)("td",{className:"amount expense",children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Expense","billy"),u),placeholder:(0,l.__)("0","billy"),value:null!=_?_:"",onChange:e=>{v({earning:"",expense:e>0?Number(e):""}),g()}})}),(0,r.jsx)("td",{className:"amount tax",children:(0,r.jsx)(a.TextControl,{type:"number",label:(0,l.sprintf)((0,l.__)("%1$s in %2$s","billy"),(0,l.__)("Tax","billy"),u),placeholder:(0,l.__)("0","billy"),value:null!=j?j:"",onChange:e=>{v({tax:e>0?Number(e):""}),g()}})})]})})})]})}),save:e=>{const{attributes:{index:t,locale:a,date:n,quarter:i,earning:c,expense:o,tax:u,reference:b,postLink:x}}=e;return(0,r.jsxs)("tr",{"data-date":n&&new Date(n).toISOString().substring(0,10),"data-quarter":i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i),"data-reference":b&&b,"data-earning":c>0?c:null,"data-expense":o>0?o:null,"data-tax":u>0?u:null,children:[(0,r.jsx)("th",{className:"index",scope:"row",children:t&&t}),(0,r.jsxs)("td",{className:"date","data-value":n&&new Date(n).toISOString().substring(0,10),children:[n&&new Date(n).toISOString().substring(0,10),(0,r.jsx)("sub",{children:i&&(0,l.sprintf)((0,l.__)("Q%s","billy"),i)})]}),(0,r.jsx)("td",{className:"description",children:(0,r.jsx)(s.InnerBlocks.Content,{})}),(0,r.jsxs)("td",{className:"reference",children:[b&&!x&&b,b&&x&&(0,r.jsx)("a",{href:x,children:b})]}),(0,r.jsx)("td",{className:"amount earning","data-value":c>0?c:null,children:c&&c>0&&d(c,a)}),(0,r.jsx)("td",{className:"amount expense","data-value":o>0?o:null,children:o&&o>0&&d(o,a)}),u&&u>0&&(0,r.jsx)("td",{className:"amount tax","data-value":u,children:d(u,a)})]})},deprecated:f}),(0,t.registerBlockType)("billy-blocks/accounting-actions",{apiVersion:2,title:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Accounting","billy"),(0,l.__)("Actions","billy")),icon:"menu-alt",category:"billy-blocks",supports:{inserter:!1,reusable:!1,html:!1},getEditWrapperProps:()=>({"data-align":"wide"}),edit:(0,c.withSelect)(e=>({postModifiedDate:e("core/editor").getEditedPostAttribute("modified")}))(e=>{const{postModifiedDate:t}=e,a=(0,s.useBlockProps)({className:"components-placeholder",style:{minHeight:"auto"}});return(0,r.jsx)("div",{...a,children:(0,r.jsx)("small",{children:(0,l.sprintf)((0,l.__)("%1$s: %2$s","billy"),(0,l.__)("Last modified","billy"),new Date(t).toLocaleString())})})}),save:()=>null});const N=window.wp.plugins,$=window.wp.editor;(0,N.registerPlugin)("billy-setup",{render:()=>(0,r.jsxs)($.PluginDocumentSettingPanel,{name:"billy-setup",title:(0,l.__)("Billy Setup","billy"),className:"my-document-setting-plugin",children:[(0,r.jsx)("p",{children:(0,r.jsx)("a",{href:globalDataBilly.wpAdmin+"customize.php?autofocus[panel]=billy_setup_panel",children:(0,l.__)("Settings (Theme Customizer)","billy")})}),(0,r.jsxs)("ul",{className:"ul code",children:[(0,r.jsx)("li",{title:(0,l.__)("Invoice number","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/invoice-number"})}),(0,r.jsx)("li",{title:(0,l.__)("Quote number","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/quote-number"})}),(0,r.jsx)("li",{title:(0,l.__)("Name","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"name"}})}),(0,r.jsx)("li",{title:(0,l.__)("Address","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"address"}})}),(0,r.jsx)("li",{title:(0,l.__)("VAT","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"vat"}})}),(0,r.jsx)("li",{title:(0,l.__)("Currency","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"currency"}})}),(0,r.jsx)("li",{title:(0,l.__)("Taxes","billy"),children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:{themeMod:"taxrates"}})})]})]})}),(0,t.registerBlockType)("billy-blocks/theme-mod",{apiVersion:2,title:(0,l.__)("Theme Mod","billy"),icon:"admin-generic",category:"billy-blocks",attributes:{themeMod:{type:"string",default:""}},supports:{inserter:!1,reusable:!1,html:!1},edit:e=>{const{attributes:{themeMod:t},setAttributes:n}=e,c=(0,s.useBlockProps)();return(0,r.jsxs)("div",{...c,children:[(0,r.jsx)(s.InspectorControls,{children:(0,r.jsx)(a.PanelBody,{title:(0,l.__)("Theme Mod","billy"),children:(0,r.jsx)(a.SelectControl,{label:(0,l.__)("Setting","billy"),help:(0,l.__)("Modify the value in the Theme Customizer.","billy"),options:globalDataBilly.themeModOptions,value:null!=t?t:"",onChange:e=>{n({themeMod:e})}})})}),(0,r.jsx)(a.Disabled,{children:(0,r.jsx)(i(),{block:"billy-blocks/theme-mod",attributes:e.attributes})})]})},save:()=>null})})();
  • billy/trunk/inc/class-billy.php

    r3355121 r3361573  
    436436        }
    437437
    438         return '<div id="' . esc_attr( $post_type ) . '" class="' . esc_attr( $post_type ) . '-wrapper' . ( ! in_array( $post_type, array( 'billy-contact' ), true ) ? ' alignwide' : '' ) . '">' . $this->preheader_render_callback() . $content . '</div>';
     438        return '<div id="' . esc_attr( $post_type ) . '" class="' . esc_attr( $post_type ) . '-wrapper' . ( ! in_array( $post_type, array( 'billy-contact' ), true ) ? ' alignwide' : '' ) . '">' . ( ! in_array( $post_type, array( 'billy-contact' ), true ) ? $this->preheader_render_callback() : '' ) . $content . '</div>';
    439439    }
    440440
     
    15521552                wp_enqueue_style( 'dashicons' );
    15531553
    1554                 wp_enqueue_style( 'billy-style', self::$plugin_url . 'assets/css/main.css', array(), self::$plugin_version );
     1554                wp_enqueue_style( 'billy-style', self::$plugin_url . 'build/main.css', array(), self::$plugin_version );
    15551555                if ( is_rtl() ) {
    1556                     wp_enqueue_style( 'billy-style-rtl', self::$plugin_url . 'assets/css/rtl.css', array(), self::$plugin_version );
     1556                    wp_enqueue_style( 'billy-style-rtl', self::$plugin_url . 'build/main-rtl.css', array(), self::$plugin_version );
    15571557                }
    15581558
    15591559                // Scripts.
    1560                 wp_enqueue_script( 'billy-script', self::$plugin_url . 'assets/js/main.bundle.js', array(), self::$plugin_version, true );
     1560                wp_enqueue_script( 'billy-script', self::$plugin_url . 'build/main.js', array(), self::$plugin_version, true );
    15611561                wp_add_inline_script(
    15621562                    'billy-script',
  • billy/trunk/readme.txt

    r3355121 r3361573  
    55Requires at least: 6.0
    66Tested up to: 6.8
    7 Stable tag: 1.11.1
     7Stable tag: 1.12.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    151151== Changelog ==
    152152
     153= 1.12.0 =
     154* Refactor frontend assets and blocks
     155* Drop gulp.js and only use @wordpress/scripts in the frontend assets build process
     156
    153157= 1.11.1 =
    154158* Re-implement workaround to improve formatting of line spacing in PDF content
Note: See TracChangeset for help on using the changeset viewer.