mcp-zenskar 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.mjs +1 -1
- package/dist/ui/app.html +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -75,7 +75,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
75
75
|
`);if(e===-1)return null;let t=this._buffer.toString(`utf8`,0,e).replace(/\r$/,``);return this._buffer=this._buffer.subarray(e+1),Tm(t)}clear(){this._buffer=void 0}};function Tm(e){return hl.parse(JSON.parse(e))}function Em(e){return JSON.stringify(e)+`
|
|
76
76
|
`}var Dm=class{constructor(e=c.stdin,t=c.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new wm,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{this.onerror?.(e)}}async start(){if(this._started)throw Error(`StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.`);this._started=!0,this._stdin.on(`data`,this._ondata),this._stdin.on(`error`,this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off(`data`,this._ondata),this._stdin.off(`error`,this._onerror),this._stdin.listenerCount(`data`)===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{let n=Em(e);this._stdout.write(n)?t():this._stdout.once(`drain`,t)})}};const Om=[];for(let e=0;e<256;++e)Om.push((e+256).toString(16).slice(1));function km(e,t=0){return(Om[e[t+0]]+Om[e[t+1]]+Om[e[t+2]]+Om[e[t+3]]+`-`+Om[e[t+4]]+Om[e[t+5]]+`-`+Om[e[t+6]]+Om[e[t+7]]+`-`+Om[e[t+8]]+Om[e[t+9]]+`-`+Om[e[t+10]]+Om[e[t+11]]+Om[e[t+12]]+Om[e[t+13]]+Om[e[t+14]]+Om[e[t+15]]).toLowerCase()}const Am=new Uint8Array(16);function jm(){return crypto.getRandomValues(Am)}function Mm(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Nm(e,t,n)}function Nm(e,t,n){e||={};let r=e.random??e.rng?.()??jm();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return km(r)}var Pm=class{constructor(){this.maxResponseLength=2e6}processResponse(e,t){try{let t=typeof e==`string`?e:JSON.stringify(e,null,2);return t.length>this.maxResponseLength&&(t=t.substring(0,this.maxResponseLength)+`
|
|
77
77
|
|
|
78
|
-
[Response truncated due to length]`),t}catch(e){return console.error(`Response processing error:`,e),`Error processing response`}}};const Fm=new Set([`getInvoiceSummary`,`getCustomerBalance`,`getPaymentStatus`]),Im={listCustomers:{shape:`customer-table`,noun:`customer`,toPayload:zm,threshold:0},listInvoices:{shape:`invoice-table`,noun:`invoice`,toPayload:Bm,threshold:0},getInvoiceLineItems:{shape:`invoice-line-items`,noun:`line item`,toPayload:Hm,threshold:0},listAllPayments:{shape:`payment-table`,noun:`payment`,toPayload:qm,threshold:0},listCreditNotes:{shape:`credit-note-table`,noun:`credit note`,toPayload:Ym,threshold:0},listContracts:{shape:`contract-table`,noun:`contract`,toPayload:Zm,threshold:0},getCustomerById:{shape:`customer-detail`,noun:`customer`,toPayload:$m,threshold:0},getInvoiceById:{shape:`invoice-detail`,noun:`invoice`,toPayload:eh,threshold:0},getContractById:{shape:`contract-detail`,noun:`contract`,toPayload:th,threshold:0},getCreditNoteById:{shape:`credit-note-detail`,noun:`credit note`,toPayload:rh,threshold:0},listProducts:{shape:`product-table`,noun:`product`,toPayload:ih,threshold:0},listPlans:{shape:`plan-table`,noun:`plan`,toPayload:oh,threshold:0},listJournalEntries:{shape:`journal-table`,noun:`journal entry`,toPayload:ch,threshold:0},listJobs:{shape:`job-table`,noun:`job`,toPayload:uh,threshold:0},listContacts:{shape:`contact-table`,noun:`contact`,toPayload:fh,threshold:0},listRawMetrics:{shape:`raw-metric-table`,noun:`raw metric`,toPayload:mh,threshold:0},listAggregates:{shape:`aggregate-table`,noun:`aggregate`,toPayload:gh,threshold:0},listCustomerAddresses:{shape:`address-list`,noun:`address`,toPayload:vh,threshold:0},listPaymentMethods:{shape:`payment-method-list`,noun:`payment method`,toPayload:bh,threshold:0},listBusinessEntities:{shape:`entity-table`,noun:`business entity`,toPayload:Sh,threshold:0},listEntitlements:{shape:`entitlement-table`,noun:`entitlement`,toPayload:wh,threshold:0},getInvoicePreviewHtml:{shape:`invoice-preview`,noun:`invoice preview`,toPayload:Ah,threshold:0}},Lm=Object.freeze([`app`]);function Rm(e){return`ui://zenskar/app.html`}function zm(e,t){let n=Q(e),r=Eh(n,[`customers`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search_name_external_id||t.search)||void 0;return{customers:r.map(Km),total:i,cursor:{next:o,prev:s},scope:c}}function Q(e){return e&&typeof e==`object`&&e.api_response&&typeof e.api_response==`object`?e.api_response:e||{}}function Bm(e,t){let n=Q(e),r=Eh(n,[`invoices`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??n.next??null,s=a.prev??n.previous??null;return{invoices:r.map(Vm),total:i,cursor:{next:o,prev:s},scope:t&&(t.customer__customer_name__ilike||t.invoice_number__like||t.status)||void 0,default_currency:`USD`}}function Vm(e){if(!e||typeof e!=`object`)return{id:``,invoice_number:null,customer_id:null,status:null,invoice_total:null,amount_due:null,due_date:null,invoice_period_begin:null,invoice_period_end:null,external_id:null,created_at:null,payment_url:null};let t=e.invoice_period||{};return{id:String(e.id||e.invoice_id||``),invoice_number:e.invoice_number??null,customer_id:e.customer_id??null,status:e.status??null,invoice_total:kh(e.net_invoice_total??e.invoice_total),amount_due:kh(e.amount_due),due_date:e.due_date??e.promise_due_date??null,invoice_period_begin:t.begin_date??e.period_begin_date??null,invoice_period_end:t.end_date_exclusive??e.period_end_date??null,external_id:e.external_id??null,created_at:e.created_at??null,payment_url:e.payment_url??null}}function Hm(e,t){let n=Q(e),r=Array.isArray(n.lines)?n.lines:Array.isArray(n)?n:[],i=kh(n.total),a=Um(r)||`USD`;return{invoice_id:t&&t.invoiceId?String(t.invoiceId):void 0,total:i,currency:a,lines:r.map(Wm)}}function Um(e){for(let t of e){if(t&&t.subtotal&&t.subtotal.unit)return t.subtotal.unit;if(t&&t.features&&t.features[0]&&t.features[0].currency)return t.features[0].currency}return null}function Wm(e){return!e||typeof e!=`object`?{name:``,description:null,pricing_model:null,subtotal:{value:null,unit:null},quantity:{value:null,unit:null},price:null,service_start_date:null,service_end_date:null,is_billed:null}:{name:e.name??e.description??``,description:e.description??null,pricing_model:e.pricing_model??null,subtotal:Gm(e.subtotal),quantity:Gm(e.quantity),price:e.price?Gm(e.price):null,service_start_date:e.service_start_date??e.billing_period_start??null,service_end_date:e.service_end_date??e.billing_period_end??null,is_billed:typeof e.is_billed==`boolean`?e.is_billed:null,line_item_type:e.line_item_type??null,is_adjustment:typeof e.is_adjustment==`boolean`?e.is_adjustment:null,adjustment_type:e.adjustment_type??null}}function Gm(e){return e?{value:kh(e.value),unit:e.unit??null,display:e.display??null}:{value:null,unit:null,display:null}}function Km(e){return!e||typeof e!=`object`?{id:``,name:null,external_id:null,email:null}:{id:String(e.id||e.customer_id||``),name:e.customer_name??e.name??null,external_id:e.external_id??null,email:e.email??e.primary_email??null,created_at:e.created_at??e.created??null}}function qm(e,t){let n=Q(e),r=Eh(n,[`payments`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search||t.customer_id||t.type||t.payment_method)||void 0;return{payments:r.map(Jm),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0,default_currency:`USD`}}function Jm(e){if(!e||typeof e!=`object`)return{id:``,external_id:null,customer_id:null,invoice_id:null,amount:null,currency:null,payment_method:null,type:null,status:null,description:null,payment_date:null,created_at:null};let t=((Array.isArray(e.payment_parts)?e.payment_parts:[]).find(e=>e&&e.invoice_id)||{}).invoice_id||e.invoice_id||null;return{id:String(e.id||e.payment_id||``),external_id:e.external_id??null,customer_id:e.customer_id??null,invoice_id:t,amount:kh(e.amount??e.value),currency:e.currency_code??e.currency??null,payment_method:e.payment_method??null,type:e.type??null,status:e.status??null,description:e.description??e.notes??null,payment_date:e.payment_date??e.received_at??e.processed_at??null,created_at:e.created_at??null}}function Ym(e,t){let n=Q(e),r=Eh(n,[`credit_notes`,`creditNotes`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.customer_id||t.invoice_id||t.status)||void 0;return{credit_notes:r.map(Xm),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0,default_currency:`USD`}}function Xm(e){return!e||typeof e!=`object`?{id:``,credit_note_number:null,customer_id:null,invoice_id:null,status:null,amount:null,currency:null,repayment_method:null,created_at:null}:{id:String(e.id||e.credit_note_id||``),credit_note_number:e.credit_note_number??null,customer_id:e.customer_id??null,invoice_id:e.invoice_id??null,status:e.status??null,amount:kh(e.amount??e.total??e.value),currency:e.currency_code??e.currency??null,repayment_method:e.repayment_method??null,created_at:e.created_at??null}}function Zm(e,t){let n=Q(e),r=Eh(n,[`contracts`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.customer_id||t.name__ilike||t.status)||void 0;return{contracts:r.map(Qm),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0}}function Qm(e){return!e||typeof e!=`object`?{id:``,customer_id:null,name:null,status:null,currency:null,start_date:null,end_date:null,created_at:null}:{id:String(e.id||e.contract_id||``),customer_id:e.customer_id??null,name:e.name??e.contract_name??null,status:e.status??e.state??null,currency:e.currency??e.currency_code??null,start_date:e.start_date??null,end_date:e.end_date??null,created_at:e.created_at??null}}function $m(e){let t=Q(e),n=t.customer??t,r=Km(n),i=n.business_entity,a=n.default_payment_method,o=Array.isArray(n.contacts)?n.contacts:[],s=Array.isArray(n.tax_info)?n.tax_info:[];return{customer:{...r,phone:n.phone_number??n.phone??n.primary_phone??null,business_entity_id:n.business_entity_id??null,business_entity_name:(i&&typeof i==`object`?i.name:null)??null,address:n.address??null,ship_to_address:n.ship_to_address??null,communications_enabled:typeof n.communications_enabled==`boolean`?n.communications_enabled:null,auto_charge_enabled:typeof n.auto_charge_enabled==`boolean`?n.auto_charge_enabled:null,custom_data:n.custom_data??null,tax_info:s.length?s.map(e=>({country_code:e.country_code??null,tax_code:e.tax_code??null,tax_id:e.tax_id??null})):null,contacts:o.length?o.map(e=>({name:[e.first_name??``,e.last_name??``].filter(Boolean).join(` `)||null,email:e.email??null,send_invoice:typeof e.send_invoice==`boolean`?e.send_invoice:null,send_contract:typeof e.send_contract==`boolean`?e.send_contract:null})):null,default_payment_method:a&&typeof a==`object`?{type:a.type??null,brand:(a.details&&a.details.brand)??a.brand??null,last4:(a.details&&a.details.last4)??a.last4??null,connector_name:a.connector_name??null}:null,updated_at:n.updated_at??null}}}function eh(e){let t=Q(e),n=t.invoice??t,r=Vm(n),i=n.customer,a=n.contract;return{invoice:{...r,paid_amount:kh(n.paid_amount??(r.invoice_total!=null&&r.amount_due!=null?r.invoice_total-r.amount_due:null)),currency:n.currency_code??n.currency??null,business_entity_id:n.business_entity_id??null,notes:n.notes??null,custom_data:n.custom_data??n.custom_attributes??null,customer_name:(i&&typeof i==`object`?i.name:null)??null,contract_id:n.contract_id??(a&&typeof a==`object`?a.id:null)??null,contract_name:(a&&typeof a==`object`?a.name:null)??null,invoice_pdf:n.invoice_pdf??null,approved_at:n.approved_at??null,paid_at:n.paid_at??null,sent_at:n.sent_at??null}}}function th(e){let t=Q(e),n=t.contract??t,r=Qm(n),i=Array.isArray(n.phases)?n.phases:[],a=n.customer,o=Array.isArray(n.tags)?n.tags:[];return{contract:{...r,description:n.description??null,custom_attributes:n.custom_attributes??null,renewal_policy:n.renewal_policy??null,anchor_date:n.anchor_date??null,plan_id:n.plan_id??null,customer_name:(a&&typeof a==`object`?a.customer_name??a.name:null)??null,contract_type:n.contract_type??null,tags:o.length?o:null,contract_link:n.contract_link??null},phases:i.map(nh)}}function nh(e){if(!e||typeof e!=`object`)return{id:null,name:null,start_date:null,end_date:null,pricing_summary:null,product_count:null};let t=Array.isArray(e.products)?e.products:[];return{id:e.id??null,name:e.name??e.phase_name??null,start_date:e.start_date??null,end_date:e.end_date??null,pricing_summary:e.pricing_summary??null,product_count:t.length||kh(e.product_count)}}function rh(e){let t=Q(e),n=t.credit_note??t.creditNote??t,r=Xm(n),i=n.customer,a=n.invoice;return{credit_note:{...r,line_items_url:n.line_items_url??null,credits_returned:kh(n.credits_returned),custom_data:n.custom_data??null,customer_name:(i&&typeof i==`object`?i.name:null)??null,invoice_number:(a&&typeof a==`object`?a.invoice_number??a.name:null)??null}}}function ih(e,t){let n=Q(e),r=Eh(n,[`products`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.name__ilike||void 0;return{products:r.map(ah),total:i,cursor:{next:o,prev:s},scope:c}}function ah(e){return!e||typeof e!=`object`?{id:``,name:null,sku:null,description:null,product_type:null,is_active:null,created_at:null}:{id:String(e.id||e.product_id||``),name:e.name??e.product_name??null,sku:e.sku??null,description:e.description??null,product_type:e.product_type??e.type??null,is_active:typeof e.is_active==`boolean`?e.is_active:null,created_at:e.created_at??null}}function oh(e,t){let n=Q(e),r=Eh(n,[`plans`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.name__ilike||t.status)||void 0;return{plans:r.map(sh),total:i,cursor:{next:o,prev:s},scope:c}}function sh(e){return!e||typeof e!=`object`?{id:``,name:null,description:null,status:null,plan_version:null,created_at:null}:{id:String(e.id||e.plan_id||``),name:e.name??e.plan_name??null,description:e.description??null,status:e.status??e.state??null,plan_version:kh(e.plan_version),created_at:e.created_at??null}}function ch(e,t){let n=Q(e),r=Eh(n,[`entries`,`journal_entries`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.search_query||void 0;return{entries:r.map(lh),total:i,cursor:{next:o,prev:s},scope:c,default_currency:`USD`}}function lh(e){if(!e||typeof e!=`object`)return{id:``,posted_at:null,event:null,description:null,status_type:null,currency:null,total_debit:null,total_credit:null,line_count:null,created_at:null};let t=Array.isArray(e.journal_lines)?e.journal_lines:[],n=0,r=0;for(let e of t)Number.isFinite(e?.debits)&&(n+=e.debits),Number.isFinite(e?.credits)&&(r+=e.credits);return{id:String(e.id||e.journal_entry_id||``),posted_at:e.posted_at??null,event:e.event??null,description:e.description??null,status_type:e.status_type??null,currency:e.currency??e.currency_code??null,total_debit:t.length?n:null,total_credit:t.length?r:null,line_count:t.length||null,created_at:e.created_at??null}}function uh(e,t){let n=Q(e),r=Eh(n,[`jobs`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.search||void 0,l={};for(let e of r){let t=e&&e.status||`unknown`;l[t]=(l[t]||0)+1}return{jobs:r.map(dh),total:i,cursor:{next:o,prev:s},scope:c,status_counts:l}}function dh(e){return!e||typeof e!=`object`?{id:``,name:null,description:null,job_type:null,resource:null,status:null,created_at:null}:{id:String(e.id||e.job_id||``),name:e.name??null,description:e.description??null,job_type:e.job_type??e.type??null,resource:e.resource??null,status:e.status??null,created_at:e.created_at??null}}function fh(e,t){let n=Q(e),r=Eh(n,[`contacts`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.customer_id||void 0;return{contacts:r.map(ph),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0}}function ph(e){if(!e||typeof e!=`object`)return{id:``,name:null,email:null,customer_id:null,send_invoice:null,send_contract:null};let t=[e.first_name??``,e.last_name??``].filter(Boolean).join(` `).trim(),n=e.customer,r=typeof n==`string`?n:(n&&typeof n==`object`?n.id:null)??e.customer_id??null;return{id:String(e.id||e.contact_id||``),name:e.name??(t||null),email:e.email??e.primary_email??null,customer_id:r??null,send_invoice:typeof e.send_invoice==`boolean`?e.send_invoice:null,send_contract:typeof e.send_contract==`boolean`?e.send_contract:null}}function mh(e,t){let n=Q(e),r=Eh(n,[`raw_metrics`,`rawmetrics`,`rawMetrics`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search||t.name__ilike)||void 0;return{raw_metrics:r.map(hh),total:i,cursor:{next:o,prev:s},scope:c}}function hh(e){return!e||typeof e!=`object`?{id:``,name:null,api_slug:null,usage_upload_enabled:null,created_at:null}:{id:String(e.id||e.raw_metric_id||``),name:e.name??null,api_slug:e.api_slug??null,usage_upload_enabled:typeof e.usage_upload_enabled==`boolean`?e.usage_upload_enabled:null,created_at:e.created_at??null}}function gh(e,t){let n=Q(e),r=Eh(n,[`aggregates`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.name__ilike||t.datasource)||void 0;return{aggregates:r.map(_h),total:i,cursor:{next:o,prev:s},scope:c}}function _h(e){return!e||typeof e!=`object`?{id:``,name:null,datasource:null,created_at:null}:{id:String(e.id||e.aggregate_id||``),name:e.name??null,datasource:e.datasource??e.data_source??e.raw_metric_name??null,created_at:e.created_at??null}}function vh(e,t){let n=Eh(Q(e),[`addresses`,`data`,`results`]);return{customer_id:t&&t.customerId?String(t.customerId):void 0,addresses:n.map(yh),total:n.length}}function yh(e){return!e||typeof e!=`object`?{id:``,label:null,line1:null,line2:null,city:null,state:null,zip_code:null,country:null,is_primary:null}:{id:String(e.id||``),label:e.label??e.name??e.address_type??null,line1:e.line1??e.address_line_1??null,line2:e.line2??e.address_line_2??null,line3:e.line3??null,city:e.city??null,state:e.state??null,zip_code:e.zipCode??e.zip_code??e.postal_code??null,country:e.country??e.country_code??null,validation_status:e.validation_status??null,is_primary:typeof e.is_primary==`boolean`?e.is_primary:typeof e.primary==`boolean`?e.primary:null}}function bh(e,t){let n=Eh(Q(e),[`payment_methods`,`paymentMethods`,`data`,`results`]);return{customer_id:t&&t.customerId?String(t.customerId):void 0,payment_methods:n.map(xh),total:n.length}}function xh(e){if(!e||typeof e!=`object`)return{id:``,type:null,brand:null,last4:null,exp_month:null,exp_year:null,is_default:null,created_at:null};let t=e.card||e.details||{};return{id:String(e.id||``),type:e.type??e.payment_method_type??null,brand:t.brand??e.brand??null,last4:t.last4??e.last4??null,exp_month:kh(t.exp_month??e.exp_month),exp_year:kh(t.exp_year??e.exp_year),is_default:typeof e.is_default==`boolean`?e.is_default:typeof e.default==`boolean`?e.default:null,created_at:e.created_at??null,connector_name:e.connector_name??null,status:e.status??null}}function Sh(e,t){let n=Q(e),r=Eh(n,[`business_entities`,`businessEntities`,`entities`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null;return{entities:r.map(Ch),total:i,cursor:{next:o,prev:s}}}function Ch(e){return!e||typeof e!=`object`?{id:``,name:null,email:null,phone_number:null,country:null,is_default:null}:{id:String(e.id||e.business_entity_id||``),name:e.name??e.business_entity_name??null,email:e.email??null,phone_number:e.phone_number??null,country:(e.address&&e.address.country)??e.country??null,is_default:typeof e.is_default==`boolean`?e.is_default:null}}function wh(e,t){let n=Q(e),r=Eh(n,[`entitlements`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search||t.name__ilike)||void 0;return{entitlements:r.map(Th),total:i,cursor:{next:o,prev:s},scope:c}}function Th(e){return!e||typeof e!=`object`?{id:``,name:null,entitlement_type:null,units:null,is_active:null,product_name:null,created_at:null}:{id:String(e.id||e.entitlement_id||``),name:e.name??null,entitlement_type:e.entitlement_type??null,units:e.units??null,is_active:typeof e.is_active==`boolean`?e.is_active:null,product_name:(e.product&&(e.product.name??e.product.product_name))??null,created_at:e.created_at??null}}function Eh(e,t){if(Array.isArray(e))return e;for(let n of t)if(e&&Array.isArray(e[n]))return e[n];return[]}function Dh(e,t){for(let n of t)if(e&&e[n]&&typeof e[n]==`object`)return e[n];return null}function Oh(e,t){for(let n of t)if(e&&Number.isFinite(e[n]))return e[n];return null}function kh(e){return Number.isFinite(e)?e:null}function Ah(e,t){let n=Q(e);return{html:n.html??(typeof n==`string`?n:``),invoice_id:t&&t.invoiceId?String(t.invoiceId):void 0}}function jh(e){if(Fm.has(e))return{mode:`text-only`};let t=Im[e];return t?{mode:`ui`,...t}:{mode:`unmapped`}}const Mh=a(s(import.meta.url)),Nh=[o(Mh,`..`,`..`,`..`,`dist`,`ui`),o(Mh,`ui`)];function Ph(e){for(let t of Nh){let i=o(t,`${e}.html`);if(n(i))return r(i,`utf8`)}return`<!doctype html><html><body style="font-family:sans-serif;padding:16px;">UI bundle missing: ${e}.html. Run <code>pnpm run build:ui</code>.</body></html>`}function Fh(){let e=new Set,t=t=>{if(t)try{e.add(new URL(t).origin)}catch{}};return t(process.env.ZENSKAR_MCP_PUBLIC_BASE_URL||process.env.MCP_PUBLIC_BASE_URL),t(process.env.ZENSKAR_API_BASE_URL),t(process.env.ZENSKAR_APP_BASE_URL),Array.from(e)}function Ih(){let e={prefersBorder:!0},t=Fh();return t.length>0&&(e.csp={connectDomains:t,resourceDomains:t}),e}function Lh(e){for(let t of Lm){let n=Rm(t);e.registerResource(`zenskar-app`,n,{},async()=>({contents:[{uri:n,mimeType:`text/html;profile=mcp-app`,text:Ph(t),_meta:{"openai/widgetPrefersBorder":!0,ui:Ih()}}]}))}}function Rh(e,t){return t===1?e:e.endsWith(`y`)?e.slice(0,-1)+`ies`:e+`s`}function zh(e,t,n){let r=Number.isFinite(t)?t:0,i=r===1?`Rendered ${e} detail view`:`Rendered ${r} ${Rh(e,r)}`,a=n?`${i} for ${n}.`:`${i}.`;return a.length>200?a.slice(0,199)+`…`:a}function Bh(){let e=process.env.ZENSKAR_MCP_UI_ENABLED;return e==null||e===``?!0:!/^(0|false|no|off)$/i.test(String(e).trim())}function Vh(){let e=process.env.ZENSKAR_MCP_UI_DISABLED_TOOLS;return e?new Set(String(e).split(`,`).map(e=>e.trim()).filter(Boolean)):new Set}const Hh=process.env.ZENSKAR_MCP_UI_DEBUG===`true`||process.env.MCP_DEBUG===`true`;function Uh(...e){Hh&&console.error(`[ui-wrap]`,...e)}function Wh(e,t,n,r){if(!Bh())return Uh(e,`skipped: ZENSKAR_MCP_UI_ENABLED explicitly disabled`),Kh(n);let i=jh(e);if(i.mode!==`ui`)return Uh(e,`skipped: not in registry, mode=`,i.mode),Kh(n);if(Vh().has(e))return Uh(e,`skipped: in ZENSKAR_MCP_UI_DISABLED_TOOLS`),Kh(n);let a;try{a=i.toPayload(t,r)}catch(t){return Uh(e,`toPayload threw:`,t.message),Kh(n)}let o=Gh(a);if(o<(i.threshold??0))return Uh(e,`below threshold:`,o,`<`,i.threshold),Kh(n);let s=zh(i.noun,o,a&&a.scope);return Uh(e,`OK shape=`,i.shape,`items=`,o,`stub=`,s),{content:[{type:`text`,text:s},{type:`text`,text:n}],structuredContent:a}}function Gh(e){if(!e||typeof e!=`object`)return 0;for(let t of[`customers`,`invoices`,`lines`,`payments`,`credit_notes`,`contracts`,`transactions`,`rows`,`items`,`data`,`addresses`,`payment_methods`,`products`,`plans`,`entries`,`jobs`,`contacts`,`raw_metrics`,`aggregates`,`entities`])if(Array.isArray(e[t]))return e[t].length;if(Number.isFinite(e.total))return e.total;for(let t of[`customer`,`invoice`,`contract`,`credit_note`])if(e[t]&&typeof e[t]==`object`)return 1;return+!!e.html}function Kh(e){return{content:[{type:`text`,text:e}]}}const qh=s(import.meta.url),Jh=i.dirname(qh),Yh={logUsage:async()=>{}},Xh=(e,t)=>({valid:!0,adjustedArgs:t,warnings:[],errors:[]}),Zh=()=>({message:`Limits validation unavailable`,severity:`info`,suggestions:[]}),$={debug:(e,t)=>{if(process.env.MCP_DEBUG===`true`){let n=new Date().toISOString();console.error(`[${n}] [MCP-DEBUG] ${e}`,t?JSON.stringify(t,null,2):``)}},info:(e,t)=>{let n=new Date().toISOString();console.error(`[${n}] [MCP-INFO] ${e}`,t?JSON.stringify(t,null,2):``)},error:(e,t)=>{let n=new Date().toISOString();console.error(`[${n}] [MCP-ERROR] ${e}`,t?JSON.stringify(t,null,2):``)},warn:(e,t)=>{let n=new Date().toISOString();console.error(`[${n}] [MCP-WARN] ${e}`,t?JSON.stringify(t,null,2):``)}},Qh=i.join(Jh,`mcp-config.json`);let $h;try{$h=JSON.parse(t.readFileSync(Qh,`utf8`))}catch(e){console.error(`Failed to load MCP config:`,e.message),console.error(`Please ensure mcp-config.json exists in the project root`),process.exit(1)}const eg=new mm({name:$h.server?.name||`zenskar-api-server`,version:`1.0.0`}),tg=new Pm;function ng(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t={...e};return typeof t.timestamp==`string`&&(t.timestamp=rg(t.timestamp)),t.data&&typeof t.data==`object`&&!Array.isArray(t.data)&&(t.data={...t.data},[`DateTime64`,`DateTime`,`DateTime32`].forEach(e=>{typeof t.data[e]==`string`&&(t.data[e]=rg(t.data[e]))})),t}function rg(e){return typeof e==`string`?e.replace(`T`,` `).replace(`t`,` `).replace(/Z$/i,``).trim():e}function ig(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t)return e;switch(t.toLowerCase()){case`boolean`:return`Bool`;case`string`:return`String`;case`int`:case`int64`:return`Int64`;case`float`:case`float64`:case`double`:return`Float64`;case`date`:case`date32`:return`Date32`;case`datetime`:case`datetime64`:return`DateTime64`;case`uuid`:return`UUID`;default:return t}}function ag(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t={...e};if(t.customer_id&&=ig(t.customer_id),t.timestamp&&=ig(t.timestamp),t.data&&typeof t.data==`object`&&!Array.isArray(t.data)){let e={};Object.entries(t.data).forEach(([t,n])=>{e[t]=ig(n)}),t.data=e}return t}function og(e){return e?Array.isArray(e)?e:Array.isArray(e.results)?e.results:e.api_response===void 0?[]:og(e.api_response):[]}function sg(e){return!e||typeof e!=`string`?`Uncategorized`:e.trim()||`Uncategorized`}function cg(e){let t=Number(e);return Number.isFinite(t)?t/100:null}function lg(e,t){let n=sg(t);return e===`getBalanceSheet`&&n===`Liabilities`?`Liabilities & Equity`:n}function ug(e,t){return(e===`getBalanceSheet`?{Assets:1,Liabilities:2,Equity:3}:{Income:1,Revenue:1,"Cost of Goods Sold":2,Expense:3,Expenses:3,"Other Income":4,"Other Expense":5,"Other Expenses":5})[t]||999}function dg(e){return`${e?.interval_start||`unknown_start`}__${e?.interval_end||`unknown_end`}`}function fg(e){return Object.values(e).sort((e,t)=>String(e.interval_start).localeCompare(String(t.interval_start)))}function pg(e,t,n){let r=new Map,i=new Map;t.forEach(t=>{let a=lg(e,t.account_category),o=dg(t),s=r.get(o)||{key:o,interval_start:t.interval_start||null,interval_end:t.interval_end||null};r.set(o,s),i.has(a)||i.set(a,{category:a,accounts:new Map,totals_by_period:{},total_balance:0,total_debits:0,total_credits:0});let c=i.get(a),l=t.account_id||`unknown_account`,u=n.get(l)||{};c.accounts.has(l)||c.accounts.set(l,{account_id:l,account_name:t.account_name||u.name||l,account_description:t.account_description||u.description||null,account_category:a,parent_path:t.account_parent_path||u.parent_path||null,balance_normality:t.balance_normality||u.balance_normality||null,periods:{},total_balance:0,total_debits:0,total_credits:0});let d=c.accounts.get(l);d.periods[o]={interval_start:t.interval_start||null,interval_end:t.interval_end||null,balance:t.balance??0,display_balance:cg(t.balance??0),debits:t.debits??0,display_debits:cg(t.debits??0),credits:t.credits??0,display_credits:cg(t.credits??0)},d.total_balance+=Number(t.balance||0),d.total_debits+=Number(t.debits||0),d.total_credits+=Number(t.credits||0);let f=c.totals_by_period[o]||{interval_start:t.interval_start||null,interval_end:t.interval_end||null,balance:0,debits:0,credits:0,display_balance:0,display_debits:0,display_credits:0};f.balance+=Number(t.balance||0),f.debits+=Number(t.debits||0),f.credits+=Number(t.credits||0),f.display_balance=cg(f.balance),f.display_debits=cg(f.debits),f.display_credits=cg(f.credits),c.totals_by_period[o]=f,c.total_balance+=Number(t.balance||0),c.total_debits+=Number(t.debits||0),c.total_credits+=Number(t.credits||0)});let a=Array.from(i.values()).sort((t,n)=>{let r=ug(e,t.category)-ug(e,n.category);return r===0?t.category.localeCompare(n.category):r}).map(e=>({category:e.category,accounts:Array.from(e.accounts.values()).sort((e,t)=>e.account_name.localeCompare(t.account_name)).map(e=>({...e,periods:fg(e.periods)})),totals_by_period:fg(e.totals_by_period),total_balance:e.total_balance,display_total_balance:cg(e.total_balance),total_debits:e.total_debits,display_total_debits:cg(e.total_debits),total_credits:e.total_credits,display_total_credits:cg(e.total_credits)}));return{report_type:e===`getBalanceSheet`?`balance_sheet`:`income_statement`,periods:Array.from(r.values()).sort((e,t)=>String(e.interval_start).localeCompare(String(t.interval_start))),sections:a}}function mg(e){if(!e)return``;let t=e.account_category||``;return t===`Liabilities`?`Liabilities & Equity`:t}function hg(e){let t=[...e].map(e=>({...e,account_category:mg(e)})).sort((e,t)=>{let n=mg(e).localeCompare(mg(t));return n===0?String(e.name||``).localeCompare(String(t.name||``)):n}),n=new Map;t.forEach(e=>{let t=mg(e)||`Uncategorized`;n.has(t)||n.set(t,[]),n.get(t).push(e)}),[`Assets`,`Liabilities & Equity`,`Equity`,`Income`,`Expenses`].forEach(e=>{n.has(e)||n.set(e,[])});let r=Array.from(n.entries()).sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>({id:e,name:e,description:e,account_category:e,is_parent:!0,parent_path:null,children:t.map(t=>({...t,parent_path:t.parent_path||e}))})),i=r.find(e=>e.name===`Liabilities & Equity`);return i&&(i.children.some(e=>e.name===`Equity`)||(i.children.push({id:`Equity`,name:`Equity`,description:`Equity`,account_category:`Liabilities & Equity`,balance_normality:`credit`,is_parent:!0,parent_path:`Liabilities & Equity`,custom_data:{default_account:!1},children:[]}),i.children.push({id:`Equity:Retained Earnings`,name:`Retained Earnings`,description:`Retained Earnings`,account_category:`Liabilities & Equity`,balance_normality:`credit`,is_parent:!1,parent_path:`Equity`,custom_data:{default_account:!1}}))),r}function gg(e){if(!e||!Array.isArray(e.results))return e;let t=e.results.reduce((e,t)=>{let n=t.status||`unknown`;return e[n]=(e[n]||0)+1,e},{});return{...e,summary:{total_count:e.total_count??e.results.length,returned_count:e.results.length,page_status_counts:t,has_more:!!e.next,note:e.next?`Showing ${e.results.length} jobs from the current page. Use the cursor to continue through the remaining jobs.`:`Showing ${e.results.length} jobs from the current page.`}}}function _g(e){if(!e||!Array.isArray(e.results))return e;let t=[...e.results].sort((e,t)=>{let n=sg(e.account_category),r=sg(t.account_category),i=n.localeCompare(r);return i===0?String(e.name||``).localeCompare(String(t.name||``)):i}),n=t.reduce((e,t)=>{let n=sg(t.account_category);return e[n]=e[n]||[],e[n].push(t),e},{});return{...e,results:t,grouped_view:n}}async function vg(e,t){let n=await fetch(e,{method:`GET`,headers:t}),r=await n.text();if(!n.ok)throw Error(`Supplemental fetch failed: ${n.status} ${n.statusText}\nResponse: ${r}`);try{return JSON.parse(r)}catch{throw Error(`Supplemental fetch returned non-JSON response: ${r}`)}}async function yg(e,t,n){let r=e.rawMetricId,i=await vg(`${n}/rawmetric/${encodeURIComponent(r)}`,t);if(!i?.api_slug)throw Error(`Unable to resolve api_slug for raw metric ${r}`);let a={...t,apiversion:`20240301`},o={limit:e.limit??20,offset:e.offset??0,order_by:e.order_by??[{column:`timestamp`,type:`DESC`}],aggregate_operation:e.aggregate_operation??null,customer_mapping:null,end_date_mapping:null,start_date_mapping:null,table_name:`raw_metric_${i.api_slug}`,visual_query:{groups:[{filters:Array.isArray(e.filters)?e.filters:[],logic:`AND`}],logic:`AND`}},s=await fetch(`${n}/aggregate/visualquery/preview`,{method:`POST`,headers:a,body:JSON.stringify(o)}),c=await s.text();if(!s.ok)throw Error(`API request failed: ${s.status} ${s.statusText}\nResponse: ${c}`);try{return JSON.parse(c)}catch{return c}}async function bg(e,t,n,r){if(!t||!Array.isArray(t.results))return t;try{let i=og(await vg(`${r}/accounting_new/chart_of_accounts`,n)),a=new Map(i.filter(e=>e&&e.id).map(e=>[e.id,e])),o=t.results.map(t=>{let n=a.get(t.account_id)||{};return{...t,account_name:n.name||t.account_id||null,account_description:n.description||null,account_category:lg(e,n.account_category),account_parent_path:n.parent_path||null,balance_normality:n.balance_normality||null,display_balance:cg(t.balance??0),display_debits:cg(t.debits??0),display_credits:cg(t.credits??0)}}),s=pg(e,o,a);if(e===`getBalanceSheet`){let e=new URLSearchParams;n.apiversion&&e.set(`apiversion`,n.apiversion);let t=await vg(`${r}/accounting_new/income_statement/v2`,n),i=Array.isArray(t?.results)?t.results:[],a={};i.forEach(e=>{let t=dg(e),n=a[t]||{interval_start:e.interval_start||null,interval_end:e.interval_end||null,balance:0,debits:0,credits:0};n.balance+=Number(e.balance||0),n.debits+=Number(e.debits||0),n.credits+=Number(e.credits||0),a[t]=n});let o=fg(Object.fromEntries(Object.entries(a).map(([e,t])=>[e,{...t,display_balance:cg(t.balance),display_debits:cg(t.debits),display_credits:cg(t.credits)}]))),c={account_id:`Equity:Retained Earnings`,account_name:`Retained Earnings (Derived)`,account_description:`Derived from the companion income statement for MCP presentation.`,account_category:`Liabilities & Equity`,parent_path:`Equity`,balance_normality:`credit`,periods:o,total_balance:o.reduce((e,t)=>e+Number(t.balance||0),0),display_total_balance:cg(o.reduce((e,t)=>e+Number(t.balance||0),0)),total_debits:o.reduce((e,t)=>e+Number(t.debits||0),0),display_total_debits:cg(o.reduce((e,t)=>e+Number(t.debits||0),0)),total_credits:o.reduce((e,t)=>e+Number(t.credits||0),0),display_total_credits:cg(o.reduce((e,t)=>e+Number(t.credits||0),0))},l=s.sections.find(e=>e.category===`Liabilities & Equity`);l||(l={category:`Liabilities & Equity`,accounts:[],totals_by_period:[],total_balance:0,display_total_balance:0,total_debits:0,display_total_debits:0,total_credits:0,display_total_credits:0},s.sections.push(l)),l.accounts.push(c)}return{...t,results:o,statement_view:s}}catch(n){return $.warn(`[${e}] Failed to enrich accounting report output; returning raw report`,{error:n.message}),t}}function xg(e){let t={};return e.forEach(e=>{let n;n=e.type===`integer`||e.type===`number`?R():e.type===`boolean`?$s():e.type===`object`?U(rc()):e.type===`array`?B(rc()):e.type===`datetime`?H([I(),R()]):I(),e.default!==void 0&&(n=n.default(e.default)),e.required||(n=n.optional()),e.description&&(n=n.describe(e.description)),t[e.name]=n}),t.__userContext=V({userId:I().optional(),authorization:I().optional(),organization:I().optional(),apiKey:I().optional(),headers:V({}).optional(),approval:V({approved:$s(),token:I().optional(),modifiedArguments:U(rc()).optional(),originalArguments:U(rc()).optional(),toolName:I().optional()}).optional()}).optional().describe(`Internal user context for multi-tenant authentication and approval workflow`),t}async function Sg(e,t){let n=Date.now();if(e.name===`getCurrentDateTime`){let e=new Date;return{currentDate:e.toISOString().split(`T`)[0],currentDateTime:e.toISOString(),timestamp:e.getTime(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,humanReadable:e.toLocaleString()}}$.debug(`[${e.name}] Raw args received:`,{argKeys:Object.keys(t),argValues:JSON.stringify(t,null,2)});let r=t.__userContext,i={...t};delete i.__userContext,$.debug(`[${e.name}] User context received:`,r?{hasUserId:!!r.userId,hasAuthorization:!!r.authorization,hasOrganization:!!r.organization,authPrefix:r.authorization?r.authorization.substring(0,20)+`...`:`none`}:`NO USER CONTEXT`);let a=e.requestTemplate?.url||`/`,o=e.requestTemplate?.method||`GET`,s=a.startsWith(`http://`)||a.startsWith(`https://`);$.debug(`[${e.name}] Executing ${o} request with args:`,JSON.stringify(i,null,2)),r&&$.debug(`[${e.name}] Using user context:`,{hasApiKey:!!r.apiKey,hasOrganization:!!r.organization,userId:r.userId}),e.args&&e.args.forEach(e=>{e.position===`path`&&i[e.name]!==void 0&&(a=a.replace(`{${e.name}}`,encodeURIComponent(i[e.name])))});let c=new URLSearchParams;e.args&&e.args.forEach(e=>{e.position===`query`&&i[e.name]!==void 0&&i[e.name]!==null&&i[e.name]!==``&&(typeof i[e.name]==`boolean`?c.append(e.name,i[e.name].toString()):Array.isArray(i[e.name])?i[e.name].forEach(t=>{c.append(e.name,t)}):c.append(e.name,i[e.name]))}),Object.keys(i).forEach(t=>{if(!c.has(t)&&i[t]!==void 0&&i[t]!==null&&i[t]!==``){let n=e.args?.some(e=>e.position===`path`&&e.name===t),r=e.args?.some(e=>e.position===`body`&&e.name===t);!n&&!r&&(typeof i[t]==`boolean`?c.append(t,i[t].toString()):Array.isArray(i[t])?i[t].forEach(e=>{c.append(t,e)}):c.append(t,i[t]))}}),c.toString()&&(a+=`?`+c.toString());let l=null;if(o!==`GET`&&o!==`DELETE`&&e.args){let t=e=>{if(typeof e==`number`)return Number.isFinite(e)?Math.floor(e):e;if(typeof e==`string`){let t=Date.parse(e);return Number.isFinite(t)?Math.floor(t/1e3):e}return e},n={};if(e.args.forEach(r=>{if(r.position===`body`&&i[r.name]!==void 0){if(r.type===`datetime`){n[r.name]=t(i[r.name]);return}if(e.name===`ingestRawMetricEvent`&&r.name===`event`){let e=ng(i[r.name]);e&&typeof e==`object`&&!Array.isArray(e)?Object.entries(e).forEach(([e,t])=>{t!==void 0&&(n[e]=t)}):n[r.name]=e}else n[r.name]=i[r.name]}}),e.name===`createCustomer`||e.name===`updateCustomer`){let t=(t,r)=>{let i={[`${t}line1`]:`line1`,[`${t}line2`]:`line2`,[`${t}line3`]:`line3`,[`${t}city`]:`city`,[`${t}state`]:`state`,[`${t}zipCode`]:`zipCode`,[`${t}country`]:`country`,[`${t}country_code`]:`country_code`},a={},o=!1;Object.entries(i).forEach(([e,t])=>{n[e]!==void 0&&(a[t]=n[e],delete n[e],o=!0)}),o&&(n[r]=a,$.debug(`[${e.name}] Transformed flat ${t}* fields into ${r} object`))};t(`address_`,`address`),t(`ship_to_`,`ship_to_address`)}if(e.name===`createBusinessEntity`&&((t,r)=>{let i={[`${t}line1`]:`line1`,[`${t}line2`]:`line2`,[`${t}line3`]:`line3`,[`${t}city`]:`city`,[`${t}state`]:`state`,[`${t}zipCode`]:`zipCode`,[`${t}country`]:`country`},a={},o=!1;Object.entries(i).forEach(([e,t])=>{n[e]!==void 0&&(a[t]=n[e],delete n[e],o=!0)}),o&&(n[r]=a,$.debug(`[${e.name}] Transformed flat ${t}* fields into ${r} object`))})(`address_`,`address`),e.name===`getInvoicePreviewHtml`&&!i.orgId){let e=r?.organization||process.env.ZENSKAR_ORGANIZATION;e&&(i.orgId=e)}if(e.name===`extractContractFromRaw`&&!n.organization_id){let t=r?.organization||process.env.ZENSKAR_ORGANIZATION;t&&(n.organization_id=t,$.debug(`[${e.name}] Auto-populated organization_id: ${t}`))}e.name===`createRawMetric`&&(n.connector||=i.connector||`push_to_zenskar`,n.api_type||=i.api_type||`PUSH`,n.dataschema||={customer_id:`string`,timestamp:`timestamp`,data:{usage_amount:`decimal`,feature_id:`string`}},n.dataschema&&=ag(n.dataschema),n.column_order=[`timestamp`]),Object.keys(n).length>0?l=JSON.stringify(n):(o===`PATCH`||o===`POST`||o===`PUT`)&&(l=`{}`)}let u={"Content-Type":`application/json`,"User-Agent":`Zenskar-MCP-Server/1.0.0`,apiversion:`20230501`},d=r?.organization||process.env.ZENSKAR_ORGANIZATION,f=r?.authorization||r?.headers?.authorization||r?.headers?.Authorization||process.env.ZENSKAR_AUTH_TOKEN,p=r?.apiKey||r?.headers?.[`x-api-key`]||process.env.ZENSKAR_API_KEY||process.env.ZENSKAR_AUTH_TOKEN;if(d)u.organisation=d;else throw $.error(`[${e.name}] SECURITY ERROR: No organization ID provided`),Error(`Organization ID is required for API access. Set ZENSKAR_ORGANIZATION env var or provide in user context.`);if(f&&f.startsWith(`eyJ`))u.Authorization=f.startsWith(`Bearer `)?f:`Bearer ${f}`;else if(p)u[`x-api-key`]=p;else throw $.error(`[${e.name}] SECURITY ERROR: No authorization provided`),Error(`Authorization is required. Set ZENSKAR_AUTH_TOKEN (JWT) or ZENSKAR_API_KEY env var.`);if(r?.headers){let e=new Set(Object.keys(u).map(e=>e.toLowerCase())),t=new Set([`__proto__`,`prototype`,`constructor`]);Object.keys(r.headers).forEach(n=>{t.has(n)||Object.prototype.hasOwnProperty.call(r.headers,n)&&r.headers[n]&&!e.has(n.toLowerCase())&&(u[n]=r.headers[n])})}$.debug(`[${e.name}] Using headers:`,{hasOrganization:!!u.organisation,hasAuthorization:!!u.Authorization,hasApiKey:!!u[`x-api-key`],source:r?.organization?`userContext`:`env`}),e.requestTemplate?.headers&&(Array.isArray(e.requestTemplate.headers)?e.requestTemplate.headers.forEach(e=>{u[e.key]=e.value}):Object.keys(e.requestTemplate.headers).forEach(t=>{u[t]=e.requestTemplate.headers[t]}));let m;if(s)m=a,$.debug(`[${e.name}] Using absolute URL: ${m}`);else{let t=process.env.ZENSKAR_API_BASE_URL||`https://api.zenskar.com`;m=t+a,$.debug(`[${e.name}] Using relative URL with base: ${t} + ${a} = ${m}`)}$.debug(`[${e.name}] Making ${o} request to: ${m}`),$.info(`[${e.name}] MULTI-TENANT SECURITY CHECK - Headers being sent:`,{organization:u.organisation||`MISSING`,hasAuth:!!u.Authorization,authPrefix:u.Authorization?u.Authorization.substring(0,30)+`...`:`NONE`,allHeaders:JSON.stringify(u,null,2)});try{if(e.name===`getRawMetricLogs`){let t=await yg(i,u,process.env.ZENSKAR_API_BASE_URL||`https://api.zenskar.com`);return $.debug(`[${e.name}] Successfully processed frontend-style usage-event logs`),t}let t=await fetch(m,{method:o,headers:u,body:l}),r=await t.text(),a=Date.now()-n;if($.info(`[${e.name}] Response received in ${a}ms - Status: ${t.status}, Size: ${r.length} chars`),$.info(`[${e.name}] Raw response body:`,r),!t.ok){$.error(`[${e.name}] API Error Response:`,r);let n=`API request failed: ${t.status} ${t.statusText}\nResponse: ${r}`;throw Error(n)}let s;try{s=JSON.parse(r)}catch{$.debug(`[${e.name}] Failed to parse JSON response, returning as text`),s=r}if(e.name===`getInvoicePreviewHtml`)if(typeof s==`string`)try{let e=Buffer.from(s,`base64`).toString(`utf8`);s=e.includes(`<`)?{html:e}:{html:s}}catch{s={html:s}}else s={html:``};if(e.name===`getBalanceSheet`||e.name===`getIncomeStatement`){let t=process.env.ZENSKAR_API_BASE_URL||`https://api.zenskar.com`;s=await bg(e.name,s,u,t)}return e.name===`listJobs`&&(s=gg(s)),e.name===`listAccounts`&&(s=_g(s)),e.name===`getChartOfAccounts`&&Array.isArray(s)&&(s={raw_accounts:s,chart_view:hg(s)}),e.responseTemplate?.prependBody&&(s={template_info:e.responseTemplate.prependBody,api_response:s}),$.debug(`[${e.name}] Successfully processed response`),s}catch(t){throw $.error(`[${e.name}] Network error:`,t),Error(`Network error: ${t.message}`)}}const Cg=300*1e3,wg=process.env.APPROVAL_HMAC_SECRET,Tg=!!wg,Eg=new Map,Dg=new Map;function Og(e){if(e==null)return e;if(typeof structuredClone==`function`)try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))}function kg(e){let t=e?Og(e):{};return delete t.__userContext,t}function Ag(t){return e.createHmac(`sha256`,wg).update(t).digest(`base64url`)}function jg(t,n){let r=Date.now(),i=r+Cg,a=kg(n);if(Tg){let n={toolName:t,args:a,issuedAt:r,expiresAt:i,nonce:e.randomBytes(12).toString(`base64url`)},o=Buffer.from(JSON.stringify(n),`utf8`).toString(`base64url`);return`v1.${o}.${Ag(o)}`}let o=Mm();return Eg.set(o,{toolName:t,issuedAt:r,expiresAt:i,args:a}),o}function Mg(t,n){if(!t||typeof t!=`string`)return null;if(Tg){let r=t.split(`.`);if(r.length!==3)return null;let[i,a,o]=r;if(i!==`v1`)return null;let s=Ag(a),c=Buffer.from(o,`base64url`),l=Buffer.from(s,`base64url`);if(c.length!==l.length||!e.timingSafeEqual(c,l))return null;let u;try{u=JSON.parse(Buffer.from(a,`base64url`).toString(`utf8`))}catch{return null}return u.toolName!==n||typeof u.expiresAt!=`number`||u.expiresAt<Date.now()||Dg.has(t)?null:(Dg.set(t,u.expiresAt),u)}let r=Eg.get(t);return!r||(Eg.delete(t),r.toolName!==n)||r.expiresAt<Date.now()?null:r}setInterval(()=>{let e=Date.now();for(let[t,n]of Eg)n.expiresAt<e&&Eg.delete(t);for(let[t,n]of Dg)n<e&&Dg.delete(t)},6e4).unref();function Ng(e,t){return(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0)(e.modifiedArguments)?{args:e.modifiedArguments,source:`modifiedArguments`}:{args:t.args,source:`tokenSnapshot`}}function Pg(e,t){let n=e.__userContext;Object.keys(e).forEach(t=>{t!==`__userContext`&&delete e[t]}),Object.assign(e,t),e.__userContext=n}function Fg(e,t){if(!e.needsApproval)return!1;let n=t.__userContext,r=n&&n.approval;if(r&&r.approved===!0){let n=Mg(r.token,e.name);if(n){let{args:i,source:a}=Ng(r,n);return $.info(`[${e.name}] Approval token verified; arg source=${a}`),Pg(t,i),$.info(`[${e.name}] Restored arguments for approved execution:`,Object.keys(i)),!1}$.warn(`[${e.name}] Approval received without valid token (got: ${r.token?`expired/mismatched`:`missing`}); requiring re-approval`)}return typeof e.needsApproval==`function`?e.needsApproval(t):e.needsApproval===!0}function Ig(e,t){t.__userContext;let n={...t};delete n.__userContext;let r=jg(e.name,t);return{type:`approval_required`,toolName:e.name,toolDescription:e.description,arguments:n,approvalToken:r,approvalTokenExpiresInSeconds:Math.floor(Cg/1e3),approvalConfig:e.approvalConfig||{title:`Approve ${e.name}`,description:`This action requires your approval: ${e.description}`,warningText:`Please review the parameters carefully before proceeding.`,confirmText:`Approve`,cancelText:`Cancel`},fields:(e.args||[]).map(t=>({name:t.name,label:t.description||t.name,type:Rg(t.type),required:t.required||!1,value:n[t.name],sensitive:e.approvalConfig?.sensitiveFields?.includes(t.name)||!1}))}}function Lg(e,t){let n=[];if(e===`createProductPricing`){let e=t.pricing_data;!e||typeof e!=`object`?n.push(`'pricing_data' is required and must be an object containing 'pricing_type' and 'currency'.`):(e.pricing_type||n.push(`'pricing_data.pricing_type' is required (e.g. 'per_unit', 'flat_fee', 'tiered', 'volume', 'percent', 'package').`),e.currency||n.push(`'pricing_data.currency' is required (ISO 4217, e.g. 'USD').`));let r=t.quantity;!r||typeof r!=`object`?n.push(`'quantity' is required and must be an object: {type:'fixed'|'metered', quantity?, unit?, aggregate_id?}. Without it the UI shows 0 for billing_metric.`):(r.type!==`fixed`&&r.type!==`metered`&&n.push(`'quantity.type' must be exactly 'fixed' or 'metered'.`),r.type===`fixed`&&(r.quantity==null||!r.unit)&&n.push(`'quantity.type'='fixed' requires both 'quantity' (number) and 'unit' (label string).`),r.type===`metered`&&!r.aggregate_id&&n.push(`'quantity.type'='metered' requires 'aggregate_id' (UUID of the billable metric).`));let i=t.billing_period;!i||typeof i!=`object`?n.push(`'billing_period' is required and must be an object: {cadence:'P1M'|'P3M'|'P1Y'|..., offset:'P0D'|...}. Without it the UI renders 'Undefined- Every Undefined Undefined'.`):(i.cadence||n.push(`'billing_period.cadence' is required (ISO-8601 duration: 'P1M'=monthly, 'P3M'=quarterly, 'P1Y'=yearly).`),i.offset||n.push(`'billing_period.offset' is required (ISO-8601 duration, 'P0D' for no offset).`))}if(e===`createPlan`){(!t.schedule||typeof t.schedule!=`object`||!t.schedule.duration)&&n.push(`'schedule' is required and must include 'duration' (ISO-8601, e.g. 'P1Y').`),t.status||n.push(`'status' is required: 'draft' | 'active' | 'archived'.`);let e=t.phases;!Array.isArray(e)||e.length===0?n.push(`'phases' must be a non-empty array. A plan with no phases is unusable in PlansV2 — include at least one phase with name, schedule, order, and either features or pricings.`):e.forEach((e,t)=>{if(!e||typeof e!=`object`){n.push(`'phases[${t}]' must be an object.`);return}e.name||n.push(`'phases[${t}].name' is required.`),(!e.schedule||!e.schedule.duration)&&n.push(`'phases[${t}].schedule.duration' is required (ISO-8601).`),typeof e.order!=`number`&&n.push(`'phases[${t}].order' is required (integer, 0-indexed).`),!e.features&&(!Array.isArray(e.pricings)||e.pricings.length===0)&&n.push(`'phases[${t}]' has neither 'features' nor non-empty 'pricings' — phase will be empty in the UI.`)})}if(e===`generateInvoice`){let e=e=>{if(typeof e==`number`)return Number.isInteger(e)?e:null;if(typeof e==`string`){let t=Date.parse(e);return Number.isFinite(t)?Math.floor(t/1e3):null}return null},r=e(t.from_date),i=e(t.to_date);r===null&&n.push(`'from_date' must be either an integer UNIX timestamp (seconds) or an ISO-8601 datetime string. Copy from getContractBillingCycles.start_date.`),i===null&&n.push(`'to_date' must be either an integer UNIX timestamp (seconds) or an ISO-8601 datetime string. Copy from getContractBillingCycles.end_date.`),r!==null&&i!==null&&i<=r&&n.push(`'to_date' must be strictly greater than 'from_date'.`),e(t.bill_for_date)===null&&n.push(`'bill_for_date' is REQUIRED (UNIX seconds or ISO-8601 string). Without it the API returns a $0 invoice. Copy from getContractBillingCycles.bill_for_date — do NOT compute.`),(!Number.isInteger(t.billing_cycle_start_day)||t.billing_cycle_start_day<1||t.billing_cycle_start_day>31)&&n.push(`'billing_cycle_start_day' is REQUIRED and must be an integer 1-31. Copy from getContractBillingCycles.billing_cycle_start_day.`)}return e===`pauseContract`&&(t.start_date||n.push(`'start_date' is required (ISO 8601).`),t.unpause_extension_policy||n.push(`'unpause_extension_policy' is required: 'extend' or 'overlap'.`)),{valid:n.length===0,errors:n}}function Rg(e){switch(e){case`string`:return`text`;case`integer`:case`number`:return`number`;case`boolean`:return`checkbox`;default:return`text`}}Lh(eg),$h.tools&&$h.tools.length>0&&$h.tools.forEach(e=>{$.info(`Registering tool: ${e.name}`);let t=xg(e.args||[]),n=jh(e.name),r=n.mode===`ui`?(()=>{let e=Rm(n.shape);return{"openai/outputTemplate":e,"ui/resourceUri":e,ui:{resourceUri:e}}})():void 0;eg.registerTool(e.name,{title:e.name,description:e.description,inputSchema:t,...r?{_meta:r}:{}},async t=>{let n=Date.now(),r=`success`,i=null,a=0,o=0,s=null,c=null;try{$.debug(`[${e.name}] Tool execution started`),$.info(`[${e.name}] Raw args received:`,{argKeys:Object.keys(t),hasUserContextInArgs:!!t.__userContext,userContextInArgs:t.__userContext,approvedInArgs:t.__userContext?.approved});let l=Lg(e.name,t);if(!l.valid){$.error(`[${e.name}] Tool execution blocked due to invalid arguments (pre-approval):`,l.errors),r=`blocked`,i=`invalid_args: ${l.errors.join(`; `)}`;let t={type:`invalid_arguments`,toolName:e.name,errors:l.errors};return{content:[{type:`text`,text:JSON.stringify(t,null,2)},{type:`text`,text:`ACTION_NOT_EXECUTED — INVALID_ARGUMENTS\n\nTool '${e.name}' was NOT executed because the supplied arguments are invalid or incomplete:\n\n`+l.errors.map((e,t)=>`${t+1}. ${e}`).join(`
|
|
78
|
+
[Response truncated due to length]`),t}catch(e){return console.error(`Response processing error:`,e),`Error processing response`}}};const Fm=new Set([`getInvoiceSummary`,`getCustomerBalance`,`getPaymentStatus`]),Im={listCustomers:{shape:`customer-table`,noun:`customer`,toPayload:zm,threshold:0},listInvoices:{shape:`invoice-table`,noun:`invoice`,toPayload:Bm,threshold:0},getInvoiceLineItems:{shape:`invoice-line-items`,noun:`line item`,toPayload:Hm,threshold:0},listAllPayments:{shape:`payment-table`,noun:`payment`,toPayload:qm,threshold:0},listCreditNotes:{shape:`credit-note-table`,noun:`credit note`,toPayload:Ym,threshold:0},listContracts:{shape:`contract-table`,noun:`contract`,toPayload:Zm,threshold:0},getCustomerById:{shape:`customer-detail`,noun:`customer`,toPayload:$m,threshold:0},getInvoiceById:{shape:`invoice-detail`,noun:`invoice`,toPayload:eh,threshold:0},getContractById:{shape:`contract-detail`,noun:`contract`,toPayload:th,threshold:0},getCreditNoteById:{shape:`credit-note-detail`,noun:`credit note`,toPayload:rh,threshold:0},listProducts:{shape:`product-table`,noun:`product`,toPayload:ih,threshold:0},listPlans:{shape:`plan-table`,noun:`plan`,toPayload:oh,threshold:0},listJournalEntries:{shape:`journal-table`,noun:`journal entry`,toPayload:ch,threshold:0},listJobs:{shape:`job-table`,noun:`job`,toPayload:uh,threshold:0},listContacts:{shape:`contact-table`,noun:`contact`,toPayload:fh,threshold:0},listRawMetrics:{shape:`raw-metric-table`,noun:`raw metric`,toPayload:mh,threshold:0},listAggregates:{shape:`aggregate-table`,noun:`aggregate`,toPayload:gh,threshold:0},listCustomerAddresses:{shape:`address-list`,noun:`address`,toPayload:vh,threshold:0},listPaymentMethods:{shape:`payment-method-list`,noun:`payment method`,toPayload:bh,threshold:0},listBusinessEntities:{shape:`entity-table`,noun:`business entity`,toPayload:Sh,threshold:0},listEntitlements:{shape:`entitlement-table`,noun:`entitlement`,toPayload:wh,threshold:0},getInvoicePreviewHtml:{shape:`invoice-preview`,noun:`invoice preview`,toPayload:Ah,threshold:0}},Lm=Object.freeze([`app`]);function Rm(e){return`ui://zenskar/app.html`}function zm(e,t){let n=Q(e),r=Eh(n,[`customers`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search_name_external_id||t.search)||void 0;return{customers:r.map(Km),total:i,cursor:{next:o,prev:s},scope:c}}function Q(e){return e&&typeof e==`object`&&e.api_response&&typeof e.api_response==`object`?e.api_response:e||{}}function Bm(e,t){let n=Q(e),r=Eh(n,[`invoices`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??n.next??null,s=a.prev??n.previous??null;return{invoices:r.map(Vm),total:i,cursor:{next:o,prev:s},scope:t&&(t.customer__customer_name__ilike||t.invoice_number__like||t.status)||void 0,default_currency:`USD`}}function Vm(e){if(!e||typeof e!=`object`)return{id:``,invoice_number:null,customer_id:null,customer_name:null,status:null,invoice_total:null,amount_due:null,due_date:null,invoice_period_begin:null,invoice_period_end:null,external_id:null,created_at:null,payment_url:null};let t=e.invoice_period||{},n=e.customer&&typeof e.customer==`object`?e.customer:null;return{id:String(e.id||e.invoice_id||``),invoice_number:e.invoice_number??null,customer_id:n?.id??e.customer_id??null,customer_name:n?.customer_name??n?.name??null,status:e.status??null,invoice_total:kh(e.net_invoice_total??e.invoice_total),amount_due:kh(e.amount_due),due_date:e.due_date??e.promise_due_date??null,invoice_period_begin:t.begin_date??e.period_begin_date??null,invoice_period_end:t.end_date_exclusive??e.period_end_date??null,external_id:e.external_id??null,created_at:e.created_at??null,payment_url:e.payment_url??null}}function Hm(e,t){let n=Q(e),r=Array.isArray(n.lines)?n.lines:Array.isArray(n)?n:[],i=kh(n.total),a=Um(r)||`USD`;return{invoice_id:t&&t.invoiceId?String(t.invoiceId):void 0,total:i,currency:a,lines:r.map(Wm)}}function Um(e){for(let t of e){if(t&&t.subtotal&&t.subtotal.unit)return t.subtotal.unit;if(t&&t.features&&t.features[0]&&t.features[0].currency)return t.features[0].currency}return null}function Wm(e){return!e||typeof e!=`object`?{name:``,description:null,pricing_model:null,subtotal:{value:null,unit:null},quantity:{value:null,unit:null},price:null,service_start_date:null,service_end_date:null,is_billed:null}:{name:e.name??e.description??``,description:e.description??null,pricing_model:e.pricing_model??null,subtotal:Gm(e.subtotal),quantity:Gm(e.quantity),price:e.price?Gm(e.price):null,service_start_date:e.service_start_date??e.billing_period_start??null,service_end_date:e.service_end_date??e.billing_period_end??null,is_billed:typeof e.is_billed==`boolean`?e.is_billed:null,line_item_type:e.line_item_type??null,is_adjustment:typeof e.is_adjustment==`boolean`?e.is_adjustment:null,adjustment_type:e.adjustment_type??null}}function Gm(e){return e?{value:kh(e.value),unit:e.unit??null,display:e.display??null}:{value:null,unit:null,display:null}}function Km(e){return!e||typeof e!=`object`?{id:``,name:null,external_id:null,email:null}:{id:String(e.id||e.customer_id||``),name:e.customer_name??e.name??null,external_id:e.external_id??null,email:e.email??e.primary_email??null,created_at:e.created_at??e.created??null}}function qm(e,t){let n=Q(e),r=Eh(n,[`payments`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search||t.customer_id||t.type||t.payment_method)||void 0;return{payments:r.map(Jm),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0,default_currency:`USD`}}function Jm(e){if(!e||typeof e!=`object`)return{id:``,external_id:null,customer_id:null,customer_name:null,invoice_id:null,invoice_name:null,amount:null,currency:null,payment_method:null,type:null,status:null,description:null,payment_date:null,created_at:null};let t=((Array.isArray(e.payment_parts)?e.payment_parts:[]).find(e=>e&&e.invoice_id)||{}).invoice_id||e.invoice_id||null,n=e.customer&&typeof e.customer==`object`?e.customer:null,r=e.invoice&&typeof e.invoice==`object`?e.invoice:null;return{id:String(e.id||e.payment_id||``),external_id:e.external_id??null,customer_id:n?.id??e.customer_id??null,customer_name:n?.customer_name??n?.name??null,invoice_id:r?.id??t,invoice_name:r?.name??r?.invoice_number??null,amount:kh(e.amount??e.value),currency:e.currency_code??e.currency??null,payment_method:e.payment_method??null,type:e.type??null,status:e.status??null,description:e.description??e.notes??null,payment_date:e.payment_date??e.received_at??e.processed_at??null,created_at:e.created_at??null}}function Ym(e,t){let n=Q(e),r=Eh(n,[`credit_notes`,`creditNotes`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.customer_id||t.invoice_id||t.status)||void 0;return{credit_notes:r.map(Xm),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0,default_currency:`USD`}}function Xm(e){if(!e||typeof e!=`object`)return{id:``,credit_note_number:null,customer_id:null,customer_name:null,invoice_id:null,invoice_name:null,status:null,amount:null,currency:null,repayment_method:null,created_at:null};let t=e.customer&&typeof e.customer==`object`?e.customer:null,n=e.invoice&&typeof e.invoice==`object`?e.invoice:null;return{id:String(e.id||e.credit_note_id||``),credit_note_number:e.credit_note_number??null,customer_id:t?.id??e.customer_id??null,customer_name:t?.customer_name??t?.name??null,invoice_id:n?.id??e.invoice_id??null,invoice_name:n?.name??n?.invoice_number??null,status:e.status??null,amount:kh(e.amount??e.total??e.value),currency:e.currency_code??e.currency??null,repayment_method:e.repayment_method??null,created_at:e.created_at??null}}function Zm(e,t){let n=Q(e),r=Eh(n,[`contracts`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.customer_id||t.name__ilike||t.status)||void 0;return{contracts:r.map(Qm),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0}}function Qm(e){if(!e||typeof e!=`object`)return{id:``,customer_id:null,customer_name:null,name:null,status:null,currency:null,start_date:null,end_date:null,created_at:null};let t=e.customer&&typeof e.customer==`object`?e.customer:null;return{id:String(e.id||e.contract_id||``),customer_id:t?.id??e.customer_id??null,customer_name:t?.customer_name??t?.name??null,name:e.name??e.contract_name??null,status:e.status??e.state??null,currency:e.currency??e.currency_code??null,start_date:e.start_date??null,end_date:e.end_date??null,created_at:e.created_at??null}}function $m(e){let t=Q(e),n=t.customer??t,r=Km(n),i=n.business_entity,a=n.default_payment_method,o=Array.isArray(n.contacts)?n.contacts:[],s=Array.isArray(n.tax_info)?n.tax_info:[];return{customer:{...r,phone:n.phone_number??n.phone??n.primary_phone??null,business_entity_id:n.business_entity_id??null,business_entity_name:(i&&typeof i==`object`?i.name:null)??null,address:n.address??null,ship_to_address:n.ship_to_address??null,communications_enabled:typeof n.communications_enabled==`boolean`?n.communications_enabled:null,auto_charge_enabled:typeof n.auto_charge_enabled==`boolean`?n.auto_charge_enabled:null,custom_data:n.custom_data??null,tax_info:s.length?s.map(e=>({country_code:e.country_code??null,tax_code:e.tax_code??null,tax_id:e.tax_id??null})):null,contacts:o.length?o.map(e=>({name:[e.first_name??``,e.last_name??``].filter(Boolean).join(` `)||null,email:e.email??null,send_invoice:typeof e.send_invoice==`boolean`?e.send_invoice:null,send_contract:typeof e.send_contract==`boolean`?e.send_contract:null})):null,default_payment_method:a&&typeof a==`object`?{type:a.type??null,brand:(a.details&&a.details.brand)??a.brand??null,last4:(a.details&&a.details.last4)??a.last4??null,connector_name:a.connector_name??null}:null,updated_at:n.updated_at??null}}}function eh(e){let t=Q(e),n=t.invoice??t,r=Vm(n),i=n.customer,a=n.contract;return{invoice:{...r,paid_amount:kh(n.paid_amount??(r.invoice_total!=null&&r.amount_due!=null?r.invoice_total-r.amount_due:null)),currency:n.currency_code??n.currency??null,business_entity_id:n.business_entity_id??null,notes:n.notes??null,custom_data:n.custom_data??n.custom_attributes??null,customer_name:(i&&typeof i==`object`?i.name:null)??null,contract_id:n.contract_id??(a&&typeof a==`object`?a.id:null)??null,contract_name:(a&&typeof a==`object`?a.name:null)??null,invoice_pdf:n.invoice_pdf??null,approved_at:n.approved_at??null,paid_at:n.paid_at??null,sent_at:n.sent_at??null}}}function th(e){let t=Q(e),n=t.contract??t,r=Qm(n),i=Array.isArray(n.phases)?n.phases:[],a=n.customer,o=Array.isArray(n.tags)?n.tags:[];return{contract:{...r,description:n.description??null,custom_attributes:n.custom_attributes??null,renewal_policy:n.renewal_policy??null,anchor_date:n.anchor_date??null,plan_id:n.plan_id??null,customer_name:(a&&typeof a==`object`?a.customer_name??a.name:null)??null,contract_type:n.contract_type??null,tags:o.length?o:null,contract_link:n.contract_link??null},phases:i.map(nh)}}function nh(e){if(!e||typeof e!=`object`)return{id:null,name:null,start_date:null,end_date:null,pricing_summary:null,product_count:null};let t=Array.isArray(e.products)?e.products:[];return{id:e.id??null,name:e.name??e.phase_name??null,start_date:e.start_date??null,end_date:e.end_date??null,pricing_summary:e.pricing_summary??null,product_count:t.length||kh(e.product_count)}}function rh(e){let t=Q(e),n=t.credit_note??t.creditNote??t,r=Xm(n),i=n.customer,a=n.invoice;return{credit_note:{...r,line_items_url:n.line_items_url??null,credits_returned:kh(n.credits_returned),custom_data:n.custom_data??null,customer_name:(i&&typeof i==`object`?i.name:null)??null,invoice_number:(a&&typeof a==`object`?a.invoice_number??a.name:null)??null}}}function ih(e,t){let n=Q(e),r=Eh(n,[`products`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.name__ilike||void 0;return{products:r.map(ah),total:i,cursor:{next:o,prev:s},scope:c}}function ah(e){return!e||typeof e!=`object`?{id:``,name:null,sku:null,description:null,product_type:null,is_active:null,created_at:null}:{id:String(e.id||e.product_id||``),name:e.name??e.product_name??null,sku:e.sku??null,description:e.description??null,product_type:e.product_type??e.type??null,is_active:typeof e.is_active==`boolean`?e.is_active:null,created_at:e.created_at??null}}function oh(e,t){let n=Q(e),r=Eh(n,[`plans`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.name__ilike||t.status)||void 0;return{plans:r.map(sh),total:i,cursor:{next:o,prev:s},scope:c}}function sh(e){return!e||typeof e!=`object`?{id:``,name:null,description:null,status:null,plan_version:null,created_at:null}:{id:String(e.id||e.plan_id||``),name:e.name??e.plan_name??null,description:e.description??null,status:e.status??e.state??null,plan_version:kh(e.plan_version),created_at:e.created_at??null}}function ch(e,t){let n=Q(e),r=Eh(n,[`entries`,`journal_entries`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.search_query||void 0;return{entries:r.map(lh),total:i,cursor:{next:o,prev:s},scope:c,default_currency:`USD`}}function lh(e){if(!e||typeof e!=`object`)return{id:``,posted_at:null,event:null,description:null,status_type:null,currency:null,total_debit:null,total_credit:null,line_count:null,created_at:null};let t=Array.isArray(e.journal_lines)?e.journal_lines:[],n=0,r=0;for(let e of t)Number.isFinite(e?.debits)&&(n+=e.debits),Number.isFinite(e?.credits)&&(r+=e.credits);return{id:String(e.id||e.journal_entry_id||``),posted_at:e.posted_at??null,event:e.event??null,description:e.description??null,status_type:e.status_type??null,currency:e.currency??e.currency_code??null,total_debit:t.length?n:null,total_credit:t.length?r:null,line_count:t.length||null,created_at:e.created_at??null}}function uh(e,t){let n=Q(e),r=Eh(n,[`jobs`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.search||void 0,l={};for(let e of r){let t=e&&e.status||`unknown`;l[t]=(l[t]||0)+1}return{jobs:r.map(dh),total:i,cursor:{next:o,prev:s},scope:c,status_counts:l}}function dh(e){return!e||typeof e!=`object`?{id:``,name:null,description:null,job_type:null,resource:null,status:null,created_at:null}:{id:String(e.id||e.job_id||``),name:e.name??null,description:e.description??null,job_type:e.job_type??e.type??null,resource:e.resource??null,status:e.status??null,created_at:e.created_at??null}}function fh(e,t){let n=Q(e),r=Eh(n,[`contacts`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&t.customer_id||void 0;return{contacts:r.map(ph),total:i,cursor:{next:o,prev:s},scope:c?String(c):void 0}}function ph(e){if(!e||typeof e!=`object`)return{id:``,name:null,email:null,customer_id:null,send_invoice:null,send_contract:null};let t=[e.first_name??``,e.last_name??``].filter(Boolean).join(` `).trim(),n=e.customer,r=typeof n==`string`?n:(n&&typeof n==`object`?n.id:null)??e.customer_id??null;return{id:String(e.id||e.contact_id||``),name:e.name??(t||null),email:e.email??e.primary_email??null,customer_id:r??null,send_invoice:typeof e.send_invoice==`boolean`?e.send_invoice:null,send_contract:typeof e.send_contract==`boolean`?e.send_contract:null}}function mh(e,t){let n=Q(e),r=Eh(n,[`raw_metrics`,`rawmetrics`,`rawMetrics`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search||t.name__ilike)||void 0;return{raw_metrics:r.map(hh),total:i,cursor:{next:o,prev:s},scope:c}}function hh(e){return!e||typeof e!=`object`?{id:``,name:null,api_slug:null,usage_upload_enabled:null,created_at:null}:{id:String(e.id||e.raw_metric_id||``),name:e.name??null,api_slug:e.api_slug??null,usage_upload_enabled:typeof e.usage_upload_enabled==`boolean`?e.usage_upload_enabled:null,created_at:e.created_at??null}}function gh(e,t){let n=Q(e),r=Eh(n,[`aggregates`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.name__ilike||t.datasource)||void 0;return{aggregates:r.map(_h),total:i,cursor:{next:o,prev:s},scope:c}}function _h(e){return!e||typeof e!=`object`?{id:``,name:null,datasource:null,created_at:null}:{id:String(e.id||e.aggregate_id||``),name:e.name??null,datasource:e.datasource??e.data_source??e.raw_metric_name??null,created_at:e.created_at??null}}function vh(e,t){let n=Eh(Q(e),[`addresses`,`data`,`results`]);return{customer_id:t&&t.customerId?String(t.customerId):void 0,addresses:n.map(yh),total:n.length}}function yh(e){return!e||typeof e!=`object`?{id:``,label:null,line1:null,line2:null,city:null,state:null,zip_code:null,country:null,is_primary:null}:{id:String(e.id||``),label:e.label??e.name??e.address_type??null,line1:e.line1??e.address_line_1??null,line2:e.line2??e.address_line_2??null,line3:e.line3??null,city:e.city??null,state:e.state??null,zip_code:e.zipCode??e.zip_code??e.postal_code??null,country:e.country??e.country_code??null,validation_status:e.validation_status??null,is_primary:typeof e.is_primary==`boolean`?e.is_primary:typeof e.primary==`boolean`?e.primary:null}}function bh(e,t){let n=Eh(Q(e),[`payment_methods`,`paymentMethods`,`data`,`results`]);return{customer_id:t&&t.customerId?String(t.customerId):void 0,payment_methods:n.map(xh),total:n.length}}function xh(e){if(!e||typeof e!=`object`)return{id:``,type:null,brand:null,last4:null,exp_month:null,exp_year:null,is_default:null,created_at:null};let t=e.card||e.details||{};return{id:String(e.id||``),type:e.type??e.payment_method_type??null,brand:t.brand??e.brand??null,last4:t.last4??e.last4??null,exp_month:kh(t.exp_month??e.exp_month),exp_year:kh(t.exp_year??e.exp_year),is_default:typeof e.is_default==`boolean`?e.is_default:typeof e.default==`boolean`?e.default:null,created_at:e.created_at??null,connector_name:e.connector_name??null,status:e.status??null}}function Sh(e,t){let n=Q(e),r=Eh(n,[`business_entities`,`businessEntities`,`entities`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null;return{entities:r.map(Ch),total:i,cursor:{next:o,prev:s}}}function Ch(e){return!e||typeof e!=`object`?{id:``,name:null,email:null,phone_number:null,country:null,is_default:null}:{id:String(e.id||e.business_entity_id||``),name:e.name??e.business_entity_name??null,email:e.email??null,phone_number:e.phone_number??null,country:(e.address&&e.address.country)??e.country??null,is_default:typeof e.is_default==`boolean`?e.is_default:null}}function wh(e,t){let n=Q(e),r=Eh(n,[`entitlements`,`data`,`results`]),i=Oh(n,[`total`,`count`,`total_count`])??r.length,a=Dh(n,[`cursor`,`pagination`])||{},o=a.next??a.next_cursor??n.next??null,s=a.prev??a.prev_cursor??n.previous??null,c=t&&(t.search||t.name__ilike)||void 0;return{entitlements:r.map(Th),total:i,cursor:{next:o,prev:s},scope:c}}function Th(e){return!e||typeof e!=`object`?{id:``,name:null,entitlement_type:null,units:null,is_active:null,product_name:null,created_at:null}:{id:String(e.id||e.entitlement_id||``),name:e.name??null,entitlement_type:e.entitlement_type??null,units:e.units??null,is_active:typeof e.is_active==`boolean`?e.is_active:null,product_name:(e.product&&(e.product.name??e.product.product_name))??null,created_at:e.created_at??null}}function Eh(e,t){if(Array.isArray(e))return e;for(let n of t)if(e&&Array.isArray(e[n]))return e[n];return[]}function Dh(e,t){for(let n of t)if(e&&e[n]&&typeof e[n]==`object`)return e[n];return null}function Oh(e,t){for(let n of t)if(e&&Number.isFinite(e[n]))return e[n];return null}function kh(e){return Number.isFinite(e)?e:null}function Ah(e,t){let n=Q(e);return{html:n.html??(typeof n==`string`?n:``),invoice_id:t&&t.invoiceId?String(t.invoiceId):void 0}}function jh(e){if(Fm.has(e))return{mode:`text-only`};let t=Im[e];return t?{mode:`ui`,...t}:{mode:`unmapped`}}const Mh=a(s(import.meta.url)),Nh=[o(Mh,`..`,`..`,`..`,`dist`,`ui`),o(Mh,`ui`)];function Ph(e){for(let t of Nh){let i=o(t,`${e}.html`);if(n(i))return r(i,`utf8`)}return`<!doctype html><html><body style="font-family:sans-serif;padding:16px;">UI bundle missing: ${e}.html. Run <code>pnpm run build:ui</code>.</body></html>`}function Fh(){let e=new Set,t=t=>{if(t)try{e.add(new URL(t).origin)}catch{}};return t(process.env.ZENSKAR_MCP_PUBLIC_BASE_URL||process.env.MCP_PUBLIC_BASE_URL),t(process.env.ZENSKAR_API_BASE_URL),t(process.env.ZENSKAR_APP_BASE_URL),Array.from(e)}function Ih(){let e={prefersBorder:!0},t=Fh();return t.length>0&&(e.csp={connectDomains:t,resourceDomains:t}),e}function Lh(e){for(let t of Lm){let n=Rm(t);e.registerResource(`zenskar-app`,n,{},async()=>({contents:[{uri:n,mimeType:`text/html;profile=mcp-app`,text:Ph(t),_meta:{"openai/widgetPrefersBorder":!0,ui:Ih()}}]}))}}function Rh(e,t){return t===1?e:e.endsWith(`y`)?e.slice(0,-1)+`ies`:e+`s`}function zh(e,t,n){let r=Number.isFinite(t)?t:0,i=r===1?`Rendered ${e} detail view`:`Rendered ${r} ${Rh(e,r)}`,a=n?`${i} for ${n}.`:`${i}.`;return a.length>200?a.slice(0,199)+`…`:a}function Bh(){let e=process.env.ZENSKAR_MCP_UI_ENABLED;return e==null||e===``?!0:!/^(0|false|no|off)$/i.test(String(e).trim())}function Vh(){let e=process.env.ZENSKAR_MCP_UI_DISABLED_TOOLS;return e?new Set(String(e).split(`,`).map(e=>e.trim()).filter(Boolean)):new Set}const Hh=process.env.ZENSKAR_MCP_UI_DEBUG===`true`||process.env.MCP_DEBUG===`true`;function Uh(...e){Hh&&console.error(`[ui-wrap]`,...e)}function Wh(e,t,n,r){if(!Bh())return Uh(e,`skipped: ZENSKAR_MCP_UI_ENABLED explicitly disabled`),Kh(n);let i=jh(e);if(i.mode!==`ui`)return Uh(e,`skipped: not in registry, mode=`,i.mode),Kh(n);if(Vh().has(e))return Uh(e,`skipped: in ZENSKAR_MCP_UI_DISABLED_TOOLS`),Kh(n);let a;try{a=i.toPayload(t,r)}catch(t){return Uh(e,`toPayload threw:`,t.message),Kh(n)}let o=Gh(a);if(o<(i.threshold??0))return Uh(e,`below threshold:`,o,`<`,i.threshold),Kh(n);let s=zh(i.noun,o,a&&a.scope);return Uh(e,`OK shape=`,i.shape,`items=`,o,`stub=`,s),{content:[{type:`text`,text:s},{type:`text`,text:n}],structuredContent:a}}function Gh(e){if(!e||typeof e!=`object`)return 0;for(let t of[`customers`,`invoices`,`lines`,`payments`,`credit_notes`,`contracts`,`transactions`,`rows`,`items`,`data`,`addresses`,`payment_methods`,`products`,`plans`,`entries`,`jobs`,`contacts`,`raw_metrics`,`aggregates`,`entities`])if(Array.isArray(e[t]))return e[t].length;if(Number.isFinite(e.total))return e.total;for(let t of[`customer`,`invoice`,`contract`,`credit_note`])if(e[t]&&typeof e[t]==`object`)return 1;return+!!e.html}function Kh(e){return{content:[{type:`text`,text:e}]}}const qh=s(import.meta.url),Jh=i.dirname(qh),Yh={logUsage:async()=>{}},Xh=(e,t)=>({valid:!0,adjustedArgs:t,warnings:[],errors:[]}),Zh=()=>({message:`Limits validation unavailable`,severity:`info`,suggestions:[]}),$={debug:(e,t)=>{if(process.env.MCP_DEBUG===`true`){let n=new Date().toISOString();console.error(`[${n}] [MCP-DEBUG] ${e}`,t?JSON.stringify(t,null,2):``)}},info:(e,t)=>{let n=new Date().toISOString();console.error(`[${n}] [MCP-INFO] ${e}`,t?JSON.stringify(t,null,2):``)},error:(e,t)=>{let n=new Date().toISOString();console.error(`[${n}] [MCP-ERROR] ${e}`,t?JSON.stringify(t,null,2):``)},warn:(e,t)=>{let n=new Date().toISOString();console.error(`[${n}] [MCP-WARN] ${e}`,t?JSON.stringify(t,null,2):``)}},Qh=i.join(Jh,`mcp-config.json`);let $h;try{$h=JSON.parse(t.readFileSync(Qh,`utf8`))}catch(e){console.error(`Failed to load MCP config:`,e.message),console.error(`Please ensure mcp-config.json exists in the project root`),process.exit(1)}const eg=new mm({name:$h.server?.name||`zenskar-api-server`,version:`1.0.0`}),tg=new Pm;function ng(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t={...e};return typeof t.timestamp==`string`&&(t.timestamp=rg(t.timestamp)),t.data&&typeof t.data==`object`&&!Array.isArray(t.data)&&(t.data={...t.data},[`DateTime64`,`DateTime`,`DateTime32`].forEach(e=>{typeof t.data[e]==`string`&&(t.data[e]=rg(t.data[e]))})),t}function rg(e){return typeof e==`string`?e.replace(`T`,` `).replace(`t`,` `).replace(/Z$/i,``).trim():e}function ig(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t)return e;switch(t.toLowerCase()){case`boolean`:return`Bool`;case`string`:return`String`;case`int`:case`int64`:return`Int64`;case`float`:case`float64`:case`double`:return`Float64`;case`date`:case`date32`:return`Date32`;case`datetime`:case`datetime64`:return`DateTime64`;case`uuid`:return`UUID`;default:return t}}function ag(e){if(!e||typeof e!=`object`||Array.isArray(e))return e;let t={...e};if(t.customer_id&&=ig(t.customer_id),t.timestamp&&=ig(t.timestamp),t.data&&typeof t.data==`object`&&!Array.isArray(t.data)){let e={};Object.entries(t.data).forEach(([t,n])=>{e[t]=ig(n)}),t.data=e}return t}function og(e){return e?Array.isArray(e)?e:Array.isArray(e.results)?e.results:e.api_response===void 0?[]:og(e.api_response):[]}function sg(e){return!e||typeof e!=`string`?`Uncategorized`:e.trim()||`Uncategorized`}function cg(e){let t=Number(e);return Number.isFinite(t)?t/100:null}function lg(e,t){let n=sg(t);return e===`getBalanceSheet`&&n===`Liabilities`?`Liabilities & Equity`:n}function ug(e,t){return(e===`getBalanceSheet`?{Assets:1,Liabilities:2,Equity:3}:{Income:1,Revenue:1,"Cost of Goods Sold":2,Expense:3,Expenses:3,"Other Income":4,"Other Expense":5,"Other Expenses":5})[t]||999}function dg(e){return`${e?.interval_start||`unknown_start`}__${e?.interval_end||`unknown_end`}`}function fg(e){return Object.values(e).sort((e,t)=>String(e.interval_start).localeCompare(String(t.interval_start)))}function pg(e,t,n){let r=new Map,i=new Map;t.forEach(t=>{let a=lg(e,t.account_category),o=dg(t),s=r.get(o)||{key:o,interval_start:t.interval_start||null,interval_end:t.interval_end||null};r.set(o,s),i.has(a)||i.set(a,{category:a,accounts:new Map,totals_by_period:{},total_balance:0,total_debits:0,total_credits:0});let c=i.get(a),l=t.account_id||`unknown_account`,u=n.get(l)||{};c.accounts.has(l)||c.accounts.set(l,{account_id:l,account_name:t.account_name||u.name||l,account_description:t.account_description||u.description||null,account_category:a,parent_path:t.account_parent_path||u.parent_path||null,balance_normality:t.balance_normality||u.balance_normality||null,periods:{},total_balance:0,total_debits:0,total_credits:0});let d=c.accounts.get(l);d.periods[o]={interval_start:t.interval_start||null,interval_end:t.interval_end||null,balance:t.balance??0,display_balance:cg(t.balance??0),debits:t.debits??0,display_debits:cg(t.debits??0),credits:t.credits??0,display_credits:cg(t.credits??0)},d.total_balance+=Number(t.balance||0),d.total_debits+=Number(t.debits||0),d.total_credits+=Number(t.credits||0);let f=c.totals_by_period[o]||{interval_start:t.interval_start||null,interval_end:t.interval_end||null,balance:0,debits:0,credits:0,display_balance:0,display_debits:0,display_credits:0};f.balance+=Number(t.balance||0),f.debits+=Number(t.debits||0),f.credits+=Number(t.credits||0),f.display_balance=cg(f.balance),f.display_debits=cg(f.debits),f.display_credits=cg(f.credits),c.totals_by_period[o]=f,c.total_balance+=Number(t.balance||0),c.total_debits+=Number(t.debits||0),c.total_credits+=Number(t.credits||0)});let a=Array.from(i.values()).sort((t,n)=>{let r=ug(e,t.category)-ug(e,n.category);return r===0?t.category.localeCompare(n.category):r}).map(e=>({category:e.category,accounts:Array.from(e.accounts.values()).sort((e,t)=>e.account_name.localeCompare(t.account_name)).map(e=>({...e,periods:fg(e.periods)})),totals_by_period:fg(e.totals_by_period),total_balance:e.total_balance,display_total_balance:cg(e.total_balance),total_debits:e.total_debits,display_total_debits:cg(e.total_debits),total_credits:e.total_credits,display_total_credits:cg(e.total_credits)}));return{report_type:e===`getBalanceSheet`?`balance_sheet`:`income_statement`,periods:Array.from(r.values()).sort((e,t)=>String(e.interval_start).localeCompare(String(t.interval_start))),sections:a}}function mg(e){if(!e)return``;let t=e.account_category||``;return t===`Liabilities`?`Liabilities & Equity`:t}function hg(e){let t=[...e].map(e=>({...e,account_category:mg(e)})).sort((e,t)=>{let n=mg(e).localeCompare(mg(t));return n===0?String(e.name||``).localeCompare(String(t.name||``)):n}),n=new Map;t.forEach(e=>{let t=mg(e)||`Uncategorized`;n.has(t)||n.set(t,[]),n.get(t).push(e)}),[`Assets`,`Liabilities & Equity`,`Equity`,`Income`,`Expenses`].forEach(e=>{n.has(e)||n.set(e,[])});let r=Array.from(n.entries()).sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>({id:e,name:e,description:e,account_category:e,is_parent:!0,parent_path:null,children:t.map(t=>({...t,parent_path:t.parent_path||e}))})),i=r.find(e=>e.name===`Liabilities & Equity`);return i&&(i.children.some(e=>e.name===`Equity`)||(i.children.push({id:`Equity`,name:`Equity`,description:`Equity`,account_category:`Liabilities & Equity`,balance_normality:`credit`,is_parent:!0,parent_path:`Liabilities & Equity`,custom_data:{default_account:!1},children:[]}),i.children.push({id:`Equity:Retained Earnings`,name:`Retained Earnings`,description:`Retained Earnings`,account_category:`Liabilities & Equity`,balance_normality:`credit`,is_parent:!1,parent_path:`Equity`,custom_data:{default_account:!1}}))),r}function gg(e){if(!e||!Array.isArray(e.results))return e;let t=e.results.reduce((e,t)=>{let n=t.status||`unknown`;return e[n]=(e[n]||0)+1,e},{});return{...e,summary:{total_count:e.total_count??e.results.length,returned_count:e.results.length,page_status_counts:t,has_more:!!e.next,note:e.next?`Showing ${e.results.length} jobs from the current page. Use the cursor to continue through the remaining jobs.`:`Showing ${e.results.length} jobs from the current page.`}}}function _g(e){if(!e||!Array.isArray(e.results))return e;let t=[...e.results].sort((e,t)=>{let n=sg(e.account_category),r=sg(t.account_category),i=n.localeCompare(r);return i===0?String(e.name||``).localeCompare(String(t.name||``)):i}),n=t.reduce((e,t)=>{let n=sg(t.account_category);return e[n]=e[n]||[],e[n].push(t),e},{});return{...e,results:t,grouped_view:n}}async function vg(e,t){let n=await fetch(e,{method:`GET`,headers:t}),r=await n.text();if(!n.ok)throw Error(`Supplemental fetch failed: ${n.status} ${n.statusText}\nResponse: ${r}`);try{return JSON.parse(r)}catch{throw Error(`Supplemental fetch returned non-JSON response: ${r}`)}}async function yg(e,t,n){let r=e.rawMetricId,i=await vg(`${n}/rawmetric/${encodeURIComponent(r)}`,t);if(!i?.api_slug)throw Error(`Unable to resolve api_slug for raw metric ${r}`);let a={...t,apiversion:`20240301`},o={limit:e.limit??20,offset:e.offset??0,order_by:e.order_by??[{column:`timestamp`,type:`DESC`}],aggregate_operation:e.aggregate_operation??null,customer_mapping:null,end_date_mapping:null,start_date_mapping:null,table_name:`raw_metric_${i.api_slug}`,visual_query:{groups:[{filters:Array.isArray(e.filters)?e.filters:[],logic:`AND`}],logic:`AND`}},s=await fetch(`${n}/aggregate/visualquery/preview`,{method:`POST`,headers:a,body:JSON.stringify(o)}),c=await s.text();if(!s.ok)throw Error(`API request failed: ${s.status} ${s.statusText}\nResponse: ${c}`);try{return JSON.parse(c)}catch{return c}}async function bg(e,t,n,r){if(!t||!Array.isArray(t.results))return t;try{let i=og(await vg(`${r}/accounting_new/chart_of_accounts`,n)),a=new Map(i.filter(e=>e&&e.id).map(e=>[e.id,e])),o=t.results.map(t=>{let n=a.get(t.account_id)||{};return{...t,account_name:n.name||t.account_id||null,account_description:n.description||null,account_category:lg(e,n.account_category),account_parent_path:n.parent_path||null,balance_normality:n.balance_normality||null,display_balance:cg(t.balance??0),display_debits:cg(t.debits??0),display_credits:cg(t.credits??0)}}),s=pg(e,o,a);if(e===`getBalanceSheet`){let e=new URLSearchParams;n.apiversion&&e.set(`apiversion`,n.apiversion);let t=await vg(`${r}/accounting_new/income_statement/v2`,n),i=Array.isArray(t?.results)?t.results:[],a={};i.forEach(e=>{let t=dg(e),n=a[t]||{interval_start:e.interval_start||null,interval_end:e.interval_end||null,balance:0,debits:0,credits:0};n.balance+=Number(e.balance||0),n.debits+=Number(e.debits||0),n.credits+=Number(e.credits||0),a[t]=n});let o=fg(Object.fromEntries(Object.entries(a).map(([e,t])=>[e,{...t,display_balance:cg(t.balance),display_debits:cg(t.debits),display_credits:cg(t.credits)}]))),c={account_id:`Equity:Retained Earnings`,account_name:`Retained Earnings (Derived)`,account_description:`Derived from the companion income statement for MCP presentation.`,account_category:`Liabilities & Equity`,parent_path:`Equity`,balance_normality:`credit`,periods:o,total_balance:o.reduce((e,t)=>e+Number(t.balance||0),0),display_total_balance:cg(o.reduce((e,t)=>e+Number(t.balance||0),0)),total_debits:o.reduce((e,t)=>e+Number(t.debits||0),0),display_total_debits:cg(o.reduce((e,t)=>e+Number(t.debits||0),0)),total_credits:o.reduce((e,t)=>e+Number(t.credits||0),0),display_total_credits:cg(o.reduce((e,t)=>e+Number(t.credits||0),0))},l=s.sections.find(e=>e.category===`Liabilities & Equity`);l||(l={category:`Liabilities & Equity`,accounts:[],totals_by_period:[],total_balance:0,display_total_balance:0,total_debits:0,display_total_debits:0,total_credits:0,display_total_credits:0},s.sections.push(l)),l.accounts.push(c)}return{...t,results:o,statement_view:s}}catch(n){return $.warn(`[${e}] Failed to enrich accounting report output; returning raw report`,{error:n.message}),t}}function xg(e){let t={};return e.forEach(e=>{let n;n=e.type===`integer`||e.type===`number`?R():e.type===`boolean`?$s():e.type===`object`?U(rc()):e.type===`array`?B(rc()):e.type===`datetime`?H([I(),R()]):I(),e.default!==void 0&&(n=n.default(e.default)),e.required||(n=n.optional()),e.description&&(n=n.describe(e.description)),t[e.name]=n}),t.__userContext=V({userId:I().optional(),authorization:I().optional(),organization:I().optional(),apiKey:I().optional(),headers:V({}).optional(),approval:V({approved:$s(),token:I().optional(),modifiedArguments:U(rc()).optional(),originalArguments:U(rc()).optional(),toolName:I().optional()}).optional()}).optional().describe(`Internal user context for multi-tenant authentication and approval workflow`),t}async function Sg(e,t){let n=Date.now();if(e.name===`getCurrentDateTime`){let e=new Date;return{currentDate:e.toISOString().split(`T`)[0],currentDateTime:e.toISOString(),timestamp:e.getTime(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,humanReadable:e.toLocaleString()}}$.debug(`[${e.name}] Raw args received:`,{argKeys:Object.keys(t),argValues:JSON.stringify(t,null,2)});let r=t.__userContext,i={...t};delete i.__userContext,$.debug(`[${e.name}] User context received:`,r?{hasUserId:!!r.userId,hasAuthorization:!!r.authorization,hasOrganization:!!r.organization,authPrefix:r.authorization?r.authorization.substring(0,20)+`...`:`none`}:`NO USER CONTEXT`);let a=e.requestTemplate?.url||`/`,o=e.requestTemplate?.method||`GET`,s=a.startsWith(`http://`)||a.startsWith(`https://`);$.debug(`[${e.name}] Executing ${o} request with args:`,JSON.stringify(i,null,2)),r&&$.debug(`[${e.name}] Using user context:`,{hasApiKey:!!r.apiKey,hasOrganization:!!r.organization,userId:r.userId}),e.args&&e.args.forEach(e=>{e.position===`path`&&i[e.name]!==void 0&&(a=a.replace(`{${e.name}}`,encodeURIComponent(i[e.name])))});let c=new URLSearchParams;e.args&&e.args.forEach(e=>{e.position===`query`&&i[e.name]!==void 0&&i[e.name]!==null&&i[e.name]!==``&&(typeof i[e.name]==`boolean`?c.append(e.name,i[e.name].toString()):Array.isArray(i[e.name])?i[e.name].forEach(t=>{c.append(e.name,t)}):c.append(e.name,i[e.name]))}),Object.keys(i).forEach(t=>{if(!c.has(t)&&i[t]!==void 0&&i[t]!==null&&i[t]!==``){let n=e.args?.some(e=>e.position===`path`&&e.name===t),r=e.args?.some(e=>e.position===`body`&&e.name===t);!n&&!r&&(typeof i[t]==`boolean`?c.append(t,i[t].toString()):Array.isArray(i[t])?i[t].forEach(e=>{c.append(t,e)}):c.append(t,i[t]))}}),c.toString()&&(a+=`?`+c.toString());let l=null;if(o!==`GET`&&o!==`DELETE`&&e.args){let t=e=>{if(typeof e==`number`)return Number.isFinite(e)?Math.floor(e):e;if(typeof e==`string`){let t=Date.parse(e);return Number.isFinite(t)?Math.floor(t/1e3):e}return e},n={};if(e.args.forEach(r=>{if(r.position===`body`&&i[r.name]!==void 0){if(r.type===`datetime`){n[r.name]=t(i[r.name]);return}if(e.name===`ingestRawMetricEvent`&&r.name===`event`){let e=ng(i[r.name]);e&&typeof e==`object`&&!Array.isArray(e)?Object.entries(e).forEach(([e,t])=>{t!==void 0&&(n[e]=t)}):n[r.name]=e}else n[r.name]=i[r.name]}}),e.name===`createCustomer`||e.name===`updateCustomer`){let t=(t,r)=>{let i={[`${t}line1`]:`line1`,[`${t}line2`]:`line2`,[`${t}line3`]:`line3`,[`${t}city`]:`city`,[`${t}state`]:`state`,[`${t}zipCode`]:`zipCode`,[`${t}country`]:`country`,[`${t}country_code`]:`country_code`},a={},o=!1;Object.entries(i).forEach(([e,t])=>{n[e]!==void 0&&(a[t]=n[e],delete n[e],o=!0)}),o&&(n[r]=a,$.debug(`[${e.name}] Transformed flat ${t}* fields into ${r} object`))};t(`address_`,`address`),t(`ship_to_`,`ship_to_address`)}if(e.name===`createBusinessEntity`&&((t,r)=>{let i={[`${t}line1`]:`line1`,[`${t}line2`]:`line2`,[`${t}line3`]:`line3`,[`${t}city`]:`city`,[`${t}state`]:`state`,[`${t}zipCode`]:`zipCode`,[`${t}country`]:`country`},a={},o=!1;Object.entries(i).forEach(([e,t])=>{n[e]!==void 0&&(a[t]=n[e],delete n[e],o=!0)}),o&&(n[r]=a,$.debug(`[${e.name}] Transformed flat ${t}* fields into ${r} object`))})(`address_`,`address`),e.name===`getInvoicePreviewHtml`&&!i.orgId){let e=r?.organization||process.env.ZENSKAR_ORGANIZATION;e&&(i.orgId=e)}if(e.name===`extractContractFromRaw`&&!n.organization_id){let t=r?.organization||process.env.ZENSKAR_ORGANIZATION;t&&(n.organization_id=t,$.debug(`[${e.name}] Auto-populated organization_id: ${t}`))}e.name===`createRawMetric`&&(n.connector||=i.connector||`push_to_zenskar`,n.api_type||=i.api_type||`PUSH`,n.dataschema||={customer_id:`string`,timestamp:`timestamp`,data:{usage_amount:`decimal`,feature_id:`string`}},n.dataschema&&=ag(n.dataschema),n.column_order=[`timestamp`]),Object.keys(n).length>0?l=JSON.stringify(n):(o===`PATCH`||o===`POST`||o===`PUT`)&&(l=`{}`)}let u={"Content-Type":`application/json`,"User-Agent":`Zenskar-MCP-Server/1.0.0`,apiversion:`20230501`},d=r?.organization||process.env.ZENSKAR_ORGANIZATION,f=r?.authorization||r?.headers?.authorization||r?.headers?.Authorization||process.env.ZENSKAR_AUTH_TOKEN,p=r?.apiKey||r?.headers?.[`x-api-key`]||process.env.ZENSKAR_API_KEY||process.env.ZENSKAR_AUTH_TOKEN;if(d)u.organisation=d;else throw $.error(`[${e.name}] SECURITY ERROR: No organization ID provided`),Error(`Organization ID is required for API access. Set ZENSKAR_ORGANIZATION env var or provide in user context.`);if(f&&f.startsWith(`eyJ`))u.Authorization=f.startsWith(`Bearer `)?f:`Bearer ${f}`;else if(p)u[`x-api-key`]=p;else throw $.error(`[${e.name}] SECURITY ERROR: No authorization provided`),Error(`Authorization is required. Set ZENSKAR_AUTH_TOKEN (JWT) or ZENSKAR_API_KEY env var.`);if(r?.headers){let e=new Set(Object.keys(u).map(e=>e.toLowerCase())),t=new Set([`__proto__`,`prototype`,`constructor`]);Object.keys(r.headers).forEach(n=>{t.has(n)||Object.prototype.hasOwnProperty.call(r.headers,n)&&r.headers[n]&&!e.has(n.toLowerCase())&&(u[n]=r.headers[n])})}$.debug(`[${e.name}] Using headers:`,{hasOrganization:!!u.organisation,hasAuthorization:!!u.Authorization,hasApiKey:!!u[`x-api-key`],source:r?.organization?`userContext`:`env`}),e.requestTemplate?.headers&&(Array.isArray(e.requestTemplate.headers)?e.requestTemplate.headers.forEach(e=>{u[e.key]=e.value}):Object.keys(e.requestTemplate.headers).forEach(t=>{u[t]=e.requestTemplate.headers[t]}));let m;if(s)m=a,$.debug(`[${e.name}] Using absolute URL: ${m}`);else{let t=process.env.ZENSKAR_API_BASE_URL||`https://api.zenskar.com`;m=t+a,$.debug(`[${e.name}] Using relative URL with base: ${t} + ${a} = ${m}`)}$.debug(`[${e.name}] Making ${o} request to: ${m}`),$.info(`[${e.name}] MULTI-TENANT SECURITY CHECK - Headers being sent:`,{organization:u.organisation||`MISSING`,hasAuth:!!u.Authorization,authPrefix:u.Authorization?u.Authorization.substring(0,30)+`...`:`NONE`,allHeaders:JSON.stringify(u,null,2)});try{if(e.name===`getRawMetricLogs`){let t=await yg(i,u,process.env.ZENSKAR_API_BASE_URL||`https://api.zenskar.com`);return $.debug(`[${e.name}] Successfully processed frontend-style usage-event logs`),t}let t=await fetch(m,{method:o,headers:u,body:l}),r=await t.text(),a=Date.now()-n;if($.info(`[${e.name}] Response received in ${a}ms - Status: ${t.status}, Size: ${r.length} chars`),$.info(`[${e.name}] Raw response body:`,r),!t.ok){$.error(`[${e.name}] API Error Response:`,r);let n=`API request failed: ${t.status} ${t.statusText}\nResponse: ${r}`;throw Error(n)}let s;try{s=JSON.parse(r)}catch{$.debug(`[${e.name}] Failed to parse JSON response, returning as text`),s=r}if(e.name===`getInvoicePreviewHtml`)if(typeof s==`string`)try{let e=Buffer.from(s,`base64`).toString(`utf8`);s=e.includes(`<`)?{html:e}:{html:s}}catch{s={html:s}}else s={html:``};if(e.name===`getBalanceSheet`||e.name===`getIncomeStatement`){let t=process.env.ZENSKAR_API_BASE_URL||`https://api.zenskar.com`;s=await bg(e.name,s,u,t)}return e.name===`listJobs`&&(s=gg(s)),e.name===`listAccounts`&&(s=_g(s)),e.name===`getChartOfAccounts`&&Array.isArray(s)&&(s={raw_accounts:s,chart_view:hg(s)}),e.responseTemplate?.prependBody&&(s={template_info:e.responseTemplate.prependBody,api_response:s}),$.debug(`[${e.name}] Successfully processed response`),s}catch(t){throw $.error(`[${e.name}] Network error:`,t),Error(`Network error: ${t.message}`)}}const Cg=300*1e3,wg=process.env.APPROVAL_HMAC_SECRET,Tg=!!wg,Eg=new Map,Dg=new Map;function Og(e){if(e==null)return e;if(typeof structuredClone==`function`)try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))}function kg(e){let t=e?Og(e):{};return delete t.__userContext,t}function Ag(t){return e.createHmac(`sha256`,wg).update(t).digest(`base64url`)}function jg(t,n){let r=Date.now(),i=r+Cg,a=kg(n);if(Tg){let n={toolName:t,args:a,issuedAt:r,expiresAt:i,nonce:e.randomBytes(12).toString(`base64url`)},o=Buffer.from(JSON.stringify(n),`utf8`).toString(`base64url`);return`v1.${o}.${Ag(o)}`}let o=Mm();return Eg.set(o,{toolName:t,issuedAt:r,expiresAt:i,args:a}),o}function Mg(t,n){if(!t||typeof t!=`string`)return null;if(Tg){let r=t.split(`.`);if(r.length!==3)return null;let[i,a,o]=r;if(i!==`v1`)return null;let s=Ag(a),c=Buffer.from(o,`base64url`),l=Buffer.from(s,`base64url`);if(c.length!==l.length||!e.timingSafeEqual(c,l))return null;let u;try{u=JSON.parse(Buffer.from(a,`base64url`).toString(`utf8`))}catch{return null}return u.toolName!==n||typeof u.expiresAt!=`number`||u.expiresAt<Date.now()||Dg.has(t)?null:(Dg.set(t,u.expiresAt),u)}let r=Eg.get(t);return!r||(Eg.delete(t),r.toolName!==n)||r.expiresAt<Date.now()?null:r}setInterval(()=>{let e=Date.now();for(let[t,n]of Eg)n.expiresAt<e&&Eg.delete(t);for(let[t,n]of Dg)n<e&&Dg.delete(t)},6e4).unref();function Ng(e,t){return(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length>0)(e.modifiedArguments)?{args:e.modifiedArguments,source:`modifiedArguments`}:{args:t.args,source:`tokenSnapshot`}}function Pg(e,t){let n=e.__userContext;Object.keys(e).forEach(t=>{t!==`__userContext`&&delete e[t]}),Object.assign(e,t),e.__userContext=n}function Fg(e,t){if(!e.needsApproval)return!1;let n=t.__userContext,r=n&&n.approval;if(r&&r.approved===!0){let n=Mg(r.token,e.name);if(n){let{args:i,source:a}=Ng(r,n);return $.info(`[${e.name}] Approval token verified; arg source=${a}`),Pg(t,i),$.info(`[${e.name}] Restored arguments for approved execution:`,Object.keys(i)),!1}$.warn(`[${e.name}] Approval received without valid token (got: ${r.token?`expired/mismatched`:`missing`}); requiring re-approval`)}return typeof e.needsApproval==`function`?e.needsApproval(t):e.needsApproval===!0}function Ig(e,t){t.__userContext;let n={...t};delete n.__userContext;let r=jg(e.name,t);return{type:`approval_required`,toolName:e.name,toolDescription:e.description,arguments:n,approvalToken:r,approvalTokenExpiresInSeconds:Math.floor(Cg/1e3),approvalConfig:e.approvalConfig||{title:`Approve ${e.name}`,description:`This action requires your approval: ${e.description}`,warningText:`Please review the parameters carefully before proceeding.`,confirmText:`Approve`,cancelText:`Cancel`},fields:(e.args||[]).map(t=>({name:t.name,label:t.description||t.name,type:Rg(t.type),required:t.required||!1,value:n[t.name],sensitive:e.approvalConfig?.sensitiveFields?.includes(t.name)||!1}))}}function Lg(e,t){let n=[];if(e===`createProductPricing`){let e=t.pricing_data;!e||typeof e!=`object`?n.push(`'pricing_data' is required and must be an object containing 'pricing_type' and 'currency'.`):(e.pricing_type||n.push(`'pricing_data.pricing_type' is required (e.g. 'per_unit', 'flat_fee', 'tiered', 'volume', 'percent', 'package').`),e.currency||n.push(`'pricing_data.currency' is required (ISO 4217, e.g. 'USD').`));let r=t.quantity;!r||typeof r!=`object`?n.push(`'quantity' is required and must be an object: {type:'fixed'|'metered', quantity?, unit?, aggregate_id?}. Without it the UI shows 0 for billing_metric.`):(r.type!==`fixed`&&r.type!==`metered`&&n.push(`'quantity.type' must be exactly 'fixed' or 'metered'.`),r.type===`fixed`&&(r.quantity==null||!r.unit)&&n.push(`'quantity.type'='fixed' requires both 'quantity' (number) and 'unit' (label string).`),r.type===`metered`&&!r.aggregate_id&&n.push(`'quantity.type'='metered' requires 'aggregate_id' (UUID of the billable metric).`));let i=t.billing_period;!i||typeof i!=`object`?n.push(`'billing_period' is required and must be an object: {cadence:'P1M'|'P3M'|'P1Y'|..., offset:'P0D'|...}. Without it the UI renders 'Undefined- Every Undefined Undefined'.`):(i.cadence||n.push(`'billing_period.cadence' is required (ISO-8601 duration: 'P1M'=monthly, 'P3M'=quarterly, 'P1Y'=yearly).`),i.offset||n.push(`'billing_period.offset' is required (ISO-8601 duration, 'P0D' for no offset).`))}if(e===`createPlan`){(!t.schedule||typeof t.schedule!=`object`||!t.schedule.duration)&&n.push(`'schedule' is required and must include 'duration' (ISO-8601, e.g. 'P1Y').`),t.status||n.push(`'status' is required: 'draft' | 'active' | 'archived'.`);let e=t.phases;!Array.isArray(e)||e.length===0?n.push(`'phases' must be a non-empty array. A plan with no phases is unusable in PlansV2 — include at least one phase with name, schedule, order, and either features or pricings.`):e.forEach((e,t)=>{if(!e||typeof e!=`object`){n.push(`'phases[${t}]' must be an object.`);return}e.name||n.push(`'phases[${t}].name' is required.`),(!e.schedule||!e.schedule.duration)&&n.push(`'phases[${t}].schedule.duration' is required (ISO-8601).`),typeof e.order!=`number`&&n.push(`'phases[${t}].order' is required (integer, 0-indexed).`),!e.features&&(!Array.isArray(e.pricings)||e.pricings.length===0)&&n.push(`'phases[${t}]' has neither 'features' nor non-empty 'pricings' — phase will be empty in the UI.`)})}if(e===`generateInvoice`){let e=e=>{if(typeof e==`number`)return Number.isInteger(e)?e:null;if(typeof e==`string`){let t=Date.parse(e);return Number.isFinite(t)?Math.floor(t/1e3):null}return null},r=e(t.from_date),i=e(t.to_date);r===null&&n.push(`'from_date' must be either an integer UNIX timestamp (seconds) or an ISO-8601 datetime string. Copy from getContractBillingCycles.start_date.`),i===null&&n.push(`'to_date' must be either an integer UNIX timestamp (seconds) or an ISO-8601 datetime string. Copy from getContractBillingCycles.end_date.`),r!==null&&i!==null&&i<=r&&n.push(`'to_date' must be strictly greater than 'from_date'.`),e(t.bill_for_date)===null&&n.push(`'bill_for_date' is REQUIRED (UNIX seconds or ISO-8601 string). Without it the API returns a $0 invoice. Copy from getContractBillingCycles.bill_for_date — do NOT compute.`),(!Number.isInteger(t.billing_cycle_start_day)||t.billing_cycle_start_day<1||t.billing_cycle_start_day>31)&&n.push(`'billing_cycle_start_day' is REQUIRED and must be an integer 1-31. Copy from getContractBillingCycles.billing_cycle_start_day.`)}return e===`pauseContract`&&(t.start_date||n.push(`'start_date' is required (ISO 8601).`),t.unpause_extension_policy||n.push(`'unpause_extension_policy' is required: 'extend' or 'overlap'.`)),{valid:n.length===0,errors:n}}function Rg(e){switch(e){case`string`:return`text`;case`integer`:case`number`:return`number`;case`boolean`:return`checkbox`;default:return`text`}}Lh(eg),$h.tools&&$h.tools.length>0&&$h.tools.forEach(e=>{$.info(`Registering tool: ${e.name}`);let t=xg(e.args||[]),n=jh(e.name),r=n.mode===`ui`?(()=>{let e=Rm(n.shape);return{"openai/outputTemplate":e,"ui/resourceUri":e,ui:{resourceUri:e}}})():void 0;eg.registerTool(e.name,{title:e.name,description:e.description,inputSchema:t,...r?{_meta:r}:{}},async t=>{let n=Date.now(),r=`success`,i=null,a=0,o=0,s=null,c=null;try{$.debug(`[${e.name}] Tool execution started`),$.info(`[${e.name}] Raw args received:`,{argKeys:Object.keys(t),hasUserContextInArgs:!!t.__userContext,userContextInArgs:t.__userContext,approvedInArgs:t.__userContext?.approved});let l=Lg(e.name,t);if(!l.valid){$.error(`[${e.name}] Tool execution blocked due to invalid arguments (pre-approval):`,l.errors),r=`blocked`,i=`invalid_args: ${l.errors.join(`; `)}`;let t={type:`invalid_arguments`,toolName:e.name,errors:l.errors};return{content:[{type:`text`,text:JSON.stringify(t,null,2)},{type:`text`,text:`ACTION_NOT_EXECUTED — INVALID_ARGUMENTS\n\nTool '${e.name}' was NOT executed because the supplied arguments are invalid or incomplete:\n\n`+l.errors.map((e,t)=>`${t+1}. ${e}`).join(`
|
|
79
79
|
`)+`
|
|
80
80
|
|
|
81
81
|
Fix the arguments and call again. Do NOT report success to the user.`}],isError:!0}}let u=Fg(e,t),d=t.__userContext;if($.info(`[${e.name}] Approval check:`,{needsApproval:u,hasUserContext:!!d,userContextKeys:d?Object.keys(d):[],hasApprovalBlock:!!(d&&d.approval),hasToken:!!(d&&d.approval&&d.approval.token)}),u){$.info(`[${e.name}] Tool requires approval, generating approval request`);let n=Ig(e,t);return{content:[{type:`text`,text:JSON.stringify(n,null,2)},{type:`text`,text:`ACTION_NOT_EXECUTED — APPROVAL_REQUIRED\n\nTool '${e.name}' was NOT executed. The host must render an approval dialog from the JSON payload above and re-invoke this tool with __userContext.approval = {approved: true, token: '<approvalToken from payload>'} to actually perform the action. The token is single-use and expires in ${Math.floor(Cg/1e3)}s. Do NOT fabricate the token. Do NOT report success to the user; surface the dialog instead.`}],isApprovalRequired:!0,approvalRequest:n}}let f=Lg(e.name,t);if(!f.valid)return $.error(`[${e.name}] Approved arguments failed validation:`,f.errors),r=`blocked`,i=`invalid_args_post_approval: ${f.errors.join(`; `)}`,{content:[{type:`text`,text:JSON.stringify({type:`invalid_arguments`,toolName:e.name,errors:f.errors},null,2)},{type:`text`,text:`ACTION_NOT_EXECUTED — INVALID_ARGUMENTS
|
package/dist/ui/app.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
6
|
<title>app</title>
|
|
7
|
-
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),ie(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,oe(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=te(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=ie(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&le(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?(c=k(p,c,e,y),y&&f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function te(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=j(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),ue(s,s));return r}function k(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=k(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=w(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function A(e,t){return t||=[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){A(e,t)}):t.push(e)),t}function j(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ne(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function M(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ne(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function re(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]<r[l])return;return r(t.event?t.event(n):n)}}}function ie(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,w,T,E,D,O,te,k,A,j=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=n.__e=r.__e]),(d=t.__b)&&d(n);n:if(typeof j==`function`)try{if(w=n.props,T=j.prototype&&j.prototype.render,E=(d=j.contextType)&&i[d.__c],D=d?E?E.props.value:d.__:i,r.__c?x=(f=n.__c=r.__c).__=f.__E:(T?n.__c=f=new j(w,D):(n.__c=f=new C(w,D),f.constructor=j,f.render=de),E&&E.sub(f),f.state||={},f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&j.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,j.getDerivedStateFromProps(w,f.__s))),m=f.props,g=f.state,f.__v=n,p)T&&j.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&j.getDerivedStateFromProps==null&&w!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(w,D),n.__v==r.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(w,f.__s,D)){n.__v!=r.__v&&(f.props=w,f.state=f.__s,f.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(w,f.__s,D),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=D,f.props=w,f.__P=e,f.__e=!1,O=t.__r,te=0,T)f.state=f.__s,f.__d=!1,O&&O(n),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,O&&O(n),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++te<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),k=d!=null&&d.type===S&&d.key==null?se(d.props.children):d,c=ee(e,_(k)?k:[k],n,r,i,a,o,s,c,l,u),f.base=n.__e,n.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(n.__v=null,l||o!=null)if(e.then){for(n.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,n.__e=c}else{for(A=o.length;A--;)y(o[A]);ae(n)}else n.__e=r.__e,n.__k=r.__k,e.then||ae(n);t.__e(e,n,r)}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=ce(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function ae(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ae))}function oe(e,n,r){for(var i=0;i<r.length;i++)le(r[i],r[++i],r[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function se(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(se):e.constructor===void 0?v({},e):null}function ce(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(C==null)return document.createTextNode(S);n=document.createElementNS(o,C,S.is&&S),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(C==null)x===S||l&&n.data==S||(n.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(x={},d=0;d<n.attributes.length;d++)x[(g=n.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||M(n,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||M(n,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),r.__k=[];else if(p&&(n.innerHTML=``),ee(r.type==`template`?n.content:n,_(h)?h:[h],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&v==null?n.removeAttribute(`value`):v!=null&&(v!==n[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&M(n,d,v,x[d],o),d=`checked`,b!=null&&b!=n[d]&&M(n,d,b,x[d],o))}return n}function le(e,n,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&n==null||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,r)}}function ue(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||le(i,null,n)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){t.__e(e,n)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&ue(i[a],n,r||typeof e.type!=`function`);r||y(e.__e),e.__c=e.__=e.__e=void 0}function de(e,t,n){return this.constructor(e,n)}function fe(n,r,i){var a,o,s,c;r==document&&(r=document.documentElement),t.__&&t.__(n,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],ie(r,n=(!a&&i||r).__k=b(S,null,[n]),o||m,m,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?e.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),oe(s,n,c)}e=h.slice,t={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},n=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),D(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),D(this))},C.prototype.render=S,r=[],a=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=function(e,t){return e.__v.__b-t.__v.__b},O.__r=0,s=Math.random().toString(8),c=`__d`+s,l=`__a`+s,u=/(PointerCapture)$|Capture$/i,d=0,f=re(!1),p=re(!0);var N,P,pe,me,he=0,ge=[],F=t,_e=F.__b,ve=F.__r,ye=F.diffed,be=F.__c,xe=F.unmount,Se=F.__;function Ce(e,t){F.__h&&F.__h(P,e,he||t),he=0;var n=P.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return he=1,we(Ne,e)}function we(e,t,n){var r=Ce(N++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ne(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=P,!P.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};P.__f=!0;var a=P.shouldComponentUpdate,o=P.componentWillUpdate;P.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},P.shouldComponentUpdate=i}return r.__N||r.__}function Te(e,t){var n=Ce(N++,3);!F.__s&&Me(n.__H,t)&&(n.__=e,n.u=t,P.__H.__h.push(n))}function Ee(e){return he=5,L(function(){return{current:e}},[])}function L(e,t){var n=Ce(N++,7);return Me(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function De(){for(var e;e=ge.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ae),t.__h.some(je),t.__h=[]}catch(n){t.__h=[],F.__e(n,e.__v)}}}F.__b=function(e){P=null,_e&&_e(e)},F.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Se&&Se(e,t)},F.__r=function(e){ve&&ve(e),N=0;var t=(P=e.__c).__H;t&&(pe===P?(t.__h=[],P.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ae),t.__h.some(je),t.__h=[],N=0)),pe=P},F.diffed=function(e){ye&&ye(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ge.push(t)!==1&&me===F.requestAnimationFrame||((me=F.requestAnimationFrame)||ke)(De)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),pe=P=null},F.__c=function(e,t){t.some(function(e){try{e.__h.some(Ae),e.__h=e.__h.filter(function(e){return!e.__||je(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],F.__e(n,e.__v)}}),be&&be(e,t)},F.unmount=function(e){xe&&xe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ae(e)}catch(e){t=e}}),n.__H=void 0,t&&F.__e(t,n.__v))};var Oe=typeof requestAnimationFrame==`function`;function ke(e){var t,n=function(){clearTimeout(r),Oe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Oe&&(t=requestAnimationFrame(n))}function Ae(e){var t=P,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),P=t}function je(e){var t=P;e.__c=e.__(),P=t}function Me(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ne(e,t){return typeof t==`function`?t(e):t}function Pe(e,t){for(var n in t)e[n]=t[n];return e}function Fe(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Ie(e,t){this.props=e,this.context=t}(Ie.prototype=new C).isPureReactComponent=!0,Ie.prototype.shouldComponentUpdate=function(e,t){return Fe(this.props,e)||Fe(this.state,t)};var Le=t.__b;t.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Le&&Le(e)},typeof Symbol<`u`&&Symbol.for;var Re=t.__e;t.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Re(e,t,n,r)};var ze=t.unmount;function Be(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Pe({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Be(e,t,n)})),e}function Ve(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ve(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function He(){this.__u=0,this.o=null,this.__b=null}function Ue(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function We(){this.i=null,this.l=null}t.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ze&&ze(e)},(He.prototype=new C).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Ue(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ve(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},He.prototype.componentWillUnmount=function(){this.o=[]},He.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Be(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var Ge=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(We.prototype=new C).__a=function(e){var t=this,n=Ue(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Ge(t,e,r)):i()};n?n(a):a()}},We.prototype.render=function(e){this.i=null,this.l=new Map;var t=A(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},We.prototype.componentDidUpdate=We.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ge(e,n,t)})};var Ke=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,qe=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Je=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ye=/[A-Z0-9]/g,Xe=typeof document<`u`,Ze=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function Qe(e,t,n){return t.__k??(t.textContent=``),fe(e,t),typeof n==`function`&&n(),e?e.__c:null}C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(C.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var $e=t.event;t.event=function(e){return $e&&(e=$e(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var et={configurable:!0,get:function(){return this.class}},tt=t.vnode;t.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||Xe&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||Ze(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:Je.test(a)&&(a=s):s=a=`oninput`:i&&qe.test(a)?a=a.replace(Ye,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=A(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=A(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,et)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=Ke,tt&&tt(e)};var nt=t.__r;t.__r=function(e){nt&&nt(e),e.__c};var rt=t.diffed;t.diffed=function(e){rt&&rt(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function it(e){return!!e.__k&&(fe(null,e),!0)}function at(e){return{render:function(t){Qe(t,e)},unmount:function(){it(e)}}}var R=new Map,ot=1,st=new Set;typeof window<`u`&&window.addEventListener(`message`,e=>{let t=e.data;if(!t||typeof t!=`object`||t.jsonrpc!==`2.0`)return;let n=t;if(n.id!=null&&R.has(n.id)){let e=R.get(n.id);R.delete(n.id),n.error?e.reject(n.error):e.resolve(n.result);return}if(n.method){let e={jsonrpc:`2.0`,method:n.method,params:n.params};st.forEach(t=>{try{t(e)}catch{}})}});function ct(e,t,n=3e4){if(typeof window>`u`||!window.parent)return Promise.reject(Error(`no host`));let r=ot++;return new Promise((i,a)=>{let o=setTimeout(()=>{R.has(r)&&(R.delete(r),a(Error(`callHost timeout: ${e}`)))},n);R.set(r,{resolve:e=>{clearTimeout(o),i(e)},reject:e=>{clearTimeout(o),a(e)}}),window.parent.postMessage({jsonrpc:`2.0`,id:r,method:e,params:t},`*`)})}function lt(e,t){typeof window>`u`||!window.parent||window.parent.postMessage({jsonrpc:`2.0`,method:e,params:t},`*`)}var ut=`https://app.zenskar.com`;function dt(e){let t=`${ut}${e.startsWith(`/`)?e:`/${e}`}`;ct(`ui/open-link`,{url:t}).catch(()=>{try{window.open(t,`_blank`,`noopener,noreferrer`)}catch{lt(`ui/message`,{text:`Open: ${t}`})}})}function ft(e,t){let n=n=>{n.method===e&&t(n.params)};return st.add(n),()=>st.delete(n)}var pt=0;Array.isArray;function z(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--pt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function B({children:e}){return z(`span`,{className:`text-muted-foreground`,children:e})}var mt=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function ht(e){if(!e)return null;let t=e.replace(` `,`T`);/^\d{4}-\d{2}-\d{2}$/.test(t)?t+=`T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(t)||(t+=`Z`);let n=new Date(t);return Number.isNaN(n.getTime())?null:n}function gt(e){return e<10?`0`+e:String(e)}function V(e){let t=ht(e);return t?`${mt[t.getUTCMonth()]} ${gt(t.getUTCDate())}, ${t.getUTCFullYear()}`:z(B,{children:`—`})}function H(e){let t=ht(e);if(!t)return z(B,{children:`—`});let n=t.getUTCHours(),r=n>=12?`PM`:`AM`,i=n%12||12;return`${mt[t.getUTCMonth()]} ${gt(t.getUTCDate())}, ${t.getUTCFullYear()} ${gt(i)}:${gt(t.getUTCMinutes())} ${r}`}function _t(e,t=new Date){let n=ht(e);return n?Math.floor((t.getTime()-n.getTime())/864e5):null}function U(e,t=`USD`){if(e==null||!Number.isFinite(e))return z(B,{children:`—`});let n=e/100;try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:2}).format(n)}catch{return`${t} ${n.toLocaleString()}`}}function vt(e){return e?e.display?e.display:e.value==null?z(B,{children:`—`}):U(e.value,e.unit||`USD`):z(B,{children:`—`})}function W(e,t=8){return e?e.length<=t?e:e.slice(0,t)+`…`:z(B,{children:`—`})}var G=`bg-secondary/20 text-secondary ring-1 ring-secondary/30`,yt=`bg-primary/20 text-primary ring-1 ring-primary/30`,bt=`bg-destructive/20 text-destructive ring-1 ring-destructive/30`,K=`bg-muted text-muted-foreground ring-1 ring-border`,xt=`bg-accent text-accent-foreground ring-1 ring-border`,St=`bg-secondary/12 text-secondary ring-1 ring-secondary/20`,Ct={paid:G,approved:G,active:G,success:G,posted:G,upcoming:yt,partially_paid:yt,in_progress:yt,paused:yt,failed:bt,disputed:bt,draft:K,void:K,voided:K,expired:K,archived:K,issued:St,scheduled:St,refunded:xt},wt=K;function q({status:e}){if(!e)return z(B,{children:`—`});let t=Ct[e.toLowerCase()]||wt,n=Tt(e);return z(`span`,{className:`inline-block whitespace-nowrap rounded-md px-2 py-0.5 text-xs ${t}`,children:n})}function Tt(e){let t=e.replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Et({payload:e}){let t=e.addresses||[];return z(`div`,{className:`space-y-3`,children:[z(`header`,{className:`flex items-baseline justify-between gap-3`,children:z(`h2`,{className:`m-0 text-lg font-semibold`,children:[`Addresses`,` `,z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[`(`,t.length,`)`]}),e.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:[` `,`· `,e.customer_id]}):null]})}),t.length===0?z(`div`,{className:`text-muted-foreground border-border rounded-md border py-8 text-center`,children:`No addresses on file.`}):z(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:t.map((e,t)=>z(Dt,{addr:e},e.id||t))})]})}function Dt({addr:e}){return z(`article`,{className:`space-y-1 rounded-md border p-3 ${e.is_primary?`border-ring ring-ring ring-1`:`border-border`}`,children:[z(`header`,{className:`flex items-baseline justify-between gap-2`,children:[z(`div`,{className:`text-sm font-medium`,children:e.label||z(B,{children:`Untitled`})}),e.is_primary?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`primary`}):null]}),z(`div`,{className:`text-sm`,children:[e.line1?z(`div`,{children:e.line1}):null,e.line2?z(`div`,{children:e.line2}):null,e.line3?z(`div`,{children:e.line3}):null,z(`div`,{children:[e.city,e.state,e.zip_code].filter(Boolean).join(`, `)||z(B,{children:`—`})}),e.country?z(`div`,{className:`text-muted-foreground mt-0.5 text-xs uppercase`,children:e.country}):null,e.validation_status?z(`span`,{className:`mt-1 inline-block rounded-full px-2 py-0.5 text-[10px] ring-1 ${e.validation_status===`valid`?`bg-secondary/20 text-secondary ring-secondary/30`:`bg-muted text-muted-foreground ring-border`}`,children:e.validation_status}):null]})]})}function J({title:e,count:t,scope:n,rightHint:r,columns:i,rows:a,sortKey:o,sortDir:s,onSort:c,emptyMessage:l=`Nothing to show.`,showIndex:u=!0,rowKey:d,rowClassName:f,hoverRows:p=!0}){let m=i.length+ +!!u,h=r===void 0&&c?`click headers to sort`:r;return z(`div`,{className:`space-y-3`,children:[z(`header`,{className:`flex items-baseline justify-between gap-3`,children:[z(`h2`,{className:`m-0 text-lg font-semibold`,children:[e,t==null?null:z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[` `,`(`,t.toLocaleString(),`)`]}),n?z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[` `,`· `,n]}):null]}),h==null?null:z(`span`,{className:`text-muted-foreground text-xs`,children:h})]}),z(`div`,{className:`border-border overflow-auto rounded-md border`,children:z(`table`,{className:`w-full text-sm`,children:[z(`thead`,{className:`bg-muted text-muted-foreground border-b-2 border-border text-xs tracking-wide uppercase`,children:z(`tr`,{children:[u?z(Ot,{children:`#`}):null,i.map(e=>z(Ot,{align:e.align,sortable:e.sortable,active:e.sortable&&o===e.key,dir:s,onClick:e.sortable&&c?()=>c(e.key):void 0,children:e.header},e.key))]})}),z(`tbody`,{children:a.length===0?z(`tr`,{children:z(`td`,{colSpan:m,className:`text-muted-foreground py-8 text-center`,children:l})}):a.map((e,t)=>z(`tr`,{className:`border-border border-t ${p?`hover:bg-muted/60`:``} ${f?f(e,t):``}`.trim().replace(/\s+/g,` `),children:[u?z(`td`,{className:`text-muted-foreground px-3 py-2 tabular-nums`,children:t+1}):null,i.map(n=>z(`td`,{className:`px-3 py-2 ${n.align===`right`?`text-right tabular-nums`:``} ${n.className??``}`.trim(),children:n.render(e,t)},n.key))]},d?d(e,t):t))})]})})]})}function Ot({children:e,sortable:t,active:n,dir:r,onClick:i,align:a=`left`}){return z(`th`,{className:[`px-3 py-2 font-semibold`,a===`right`?`text-right`:`text-left`,t?`cursor-pointer select-none hover:text-foreground`:``,n?`text-foreground`:``].filter(Boolean).join(` `),onClick:i,children:[e,t&&n?r===`asc`?` ↑`:` ↓`:null]})}function Y({href:e,label:t=`View`}){return z(`button`,{type:`button`,className:`text-secondary hover:text-secondary/80 text-xs underline`,onClick:()=>dt(e),children:t})}function X(e,t,n){let r=n===`asc`?1:-1;return[...e].sort((e,n)=>{let i=t(e),a=t(n);return i==null&&a==null?0:i==null?1:a==null?-1:i<a?-1*r:i>a?1*r:0})}function kt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.aggregates,e=>t===`name`?e.name:e.created_at,r),[e.aggregates,t,r]);return z(J,{title:`Aggregates`,count:e.total,scope:e.scope,rightHint:`aka billable metrics`,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/meters/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No aggregates match.`,rowKey:(e,t)=>e.id||t})}function At({payload:e}){let[t,n]=I(`name`),[r,i]=I(`asc`),a=L(()=>X(e.contacts,e=>t===`name`?e.name:e.email,r),[e.contacts,t,r]);return z(J,{title:`Contacts`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`email`,header:`Email`,sortable:!0,className:`text-secondary`,render:e=>e.email||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-secondary font-mono text-xs`,render:e=>W(e.customer_id,10)},{key:`send_invoice`,header:`Send Invoice`,className:`text-xs`,render:e=>e.send_invoice==null?z(B,{children:`—`}):e.send_invoice?`yes`:`no`},{key:`send_contract`,header:`Send Contract`,className:`text-xs`,render:e=>e.send_contract==null?z(B,{children:`—`}):e.send_contract?`yes`:`no`},{key:`view`,header:`View`,render:e=>z(Y,{href:`/contacts/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`asc`))},emptyMessage:`No contacts match.`,rightHint:null,rowKey:(e,t)=>e.id||t})}var jt=`text-muted-foreground text-[11px] tracking-wide uppercase`;function Z({label:e,value:t,tone:n}){return z(`div`,{children:[z(`div`,{className:jt,children:e}),z(`div`,{className:n===`warn`?`text-2xl font-bold tabular-nums text-destructive`:`text-2xl font-bold tabular-nums`,children:t})]})}function Q({title:e,children:t}){return z(`section`,{className:`space-y-1`,children:[z(`div`,{className:jt,children:e}),t]})}function $({label:e,children:t}){return z(`div`,{children:[z(`div`,{className:jt,children:e}),z(`div`,{className:`text-sm`,children:t})]})}function Mt({payload:e}){let t=e.contract,n=e.phases||[],r=new Date;return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:[z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[t.name||z(B,{children:`—`}),t.status?z(q,{status:t.status}):null]}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]}),z(`div`,{className:`flex gap-2`,children:t.contract_link?z(`a`,{href:t.contract_link,target:`_blank`,rel:`noreferrer`,className:`border-border bg-accent text-accent-foreground hover:bg-primary hover:text-primary-foreground rounded border px-3 py-1 text-xs transition-colors`,children:`Open`}):null})]}),z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:[z($,{label:`Customer`,children:t.customer_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.customer_name}),t.customer_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.customer_id}):null]}):t.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.customer_id}):z(B,{children:`—`})}),z($,{label:`Currency`,children:t.currency?z(`span`,{className:`font-mono text-xs`,children:t.currency}):z(B,{children:`—`})}),z($,{label:`Type`,children:t.contract_type||z(B,{children:`—`})}),z($,{label:`Term`,children:t.start_date&&t.end_date?z(`span`,{className:`text-sm`,children:[t.start_date.slice(0,10),` → `,t.end_date.slice(0,10)]}):z(B,{children:`—`})}),z($,{label:`Anchor Date`,children:V(t.anchor_date)}),z($,{label:`Renewal Policy`,children:t.renewal_policy||z(B,{children:`—`})}),z($,{label:`Plan`,children:t.plan_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.plan_id}):z(B,{children:`—`})}),z($,{label:`Created`,children:V(t.created_at)})]}),t.description?z(Q,{title:`Description`,children:z(`div`,{className:`text-sm`,children:t.description})}):null,t.tags&&t.tags.length>0?z(Q,{title:`Tags`,children:z(`div`,{className:`flex flex-wrap gap-2`,children:t.tags.map((e,t)=>z(`span`,{className:`bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs`,children:e},t))})}):null,n.length>0?z(Q,{title:`Phases (${n.length})`,children:z(`div`,{className:`space-y-2`,children:n.map((e,t)=>z(Nt,{phase:e,index:t,today:r},e.id||t))})}):null,t.custom_attributes&&Object.keys(t.custom_attributes).length>0?z(Q,{title:`Custom Attributes`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_attributes).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function Nt({phase:e,index:t,today:n}){let r=e.start_date?new Date(e.start_date):null,i=e.end_date?new Date(e.end_date):null,a=r&&i&&r<=n&&n<=i;return z(`div`,{className:`border-border rounded-md border p-3 ${a?`ring-2 ring-ring`:``}`,children:[z(`div`,{className:`flex items-baseline justify-between gap-2`,children:[z(`div`,{className:`text-sm font-medium`,children:[z(`span`,{className:`text-muted-foreground mr-2`,children:[`#`,t+1]}),e.name||z(B,{children:`Untitled phase`}),a?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 ml-2 rounded-full px-2 py-0.5 text-xs ring-1`,children:`current`}):null]}),z(`div`,{className:`text-muted-foreground text-xs whitespace-nowrap`,children:[e.start_date?e.start_date.slice(0,10):`—`,` →`,` `,e.end_date?e.end_date.slice(0,10):`—`]})]}),z(`div`,{className:`mt-1 grid grid-cols-2 gap-2 text-xs sm:grid-cols-3`,children:[z(`div`,{children:[z(`span`,{className:`text-muted-foreground`,children:`Products:`}),` `,z(`span`,{className:`tabular-nums`,children:e.product_count??`—`})]}),e.pricing_summary?z(`div`,{className:`text-muted-foreground col-span-full sm:col-span-2`,children:e.pricing_summary}):null]})]})}function Pt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.contracts,e=>{switch(t){case`name`:return e.name;case`start_date`:return e.start_date;case`end_date`:return e.end_date;case`created_at`:return e.created_at??null}},r),[e.contracts,t,r]);return z(J,{title:`Contracts`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-secondary font-mono text-xs`,render:e=>W(e.customer_id,10)},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`currency`,header:`Currency`,className:`font-mono text-xs`,render:e=>e.currency||z(B,{children:`—`})},{key:`start_date`,header:`Start`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.start_date)},{key:`end_date`,header:`End`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.end_date)},{key:`days_left`,header:`Days Left`,align:`right`,render:e=>{let t=e.end_date?-1*(_t(e.end_date)??0):null;if(t==null)return z(B,{children:`—`});let n=t<0;return z(`span`,{className:n?`text-destructive font-medium`:!n&&t<=30?`text-primary font-medium`:`text-muted-foreground`,children:n?`${Math.abs(t)}d ago`:`${t}d`})}},{key:`view`,header:`View`,render:e=>z(Y,{href:`/contractsv2/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No contracts match.`,rowKey:(e,t)=>e.id||t})}function Ft({payload:e}){let t=e.credit_note,n=t.currency||`USD`;return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[z(`span`,{className:`font-mono`,children:t.credit_note_number||t.id}),t.status?z(q,{status:t.status}):null]}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]})}),z(`div`,{className:`border-border grid grid-cols-2 gap-3 rounded-md border p-3 sm:grid-cols-4`,children:[z(Z,{label:`Amount`,value:t.amount==null?z(B,{children:`—`}):U(t.amount,n)}),z(Z,{label:`Currency`,value:n}),z(Z,{label:`Credits Returned`,value:t.credits_returned==null?z(B,{children:`—`}):t.credits_returned.toLocaleString()}),z(Z,{label:`Created`,value:V(t.created_at)})]}),z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:[z($,{label:`Customer`,children:t.customer_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.customer_name}),t.customer_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.customer_id}):null]}):t.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.customer_id}):z(B,{children:`—`})}),z($,{label:`Invoice`,children:t.invoice_number?z(`div`,{children:[z(`div`,{className:`font-mono text-sm`,children:t.invoice_number}),t.invoice_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.invoice_id}):null]}):t.invoice_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.invoice_id}):z(B,{children:`—`})}),z($,{label:`Repayment Method`,children:t.repayment_method||z(B,{children:`—`})})]}),t.custom_data&&Object.keys(t.custom_data).length>0?z(Q,{title:`Custom Data`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_data).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function It({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=e.default_currency||`USD`,o=L(()=>X(e.credit_notes,e=>{switch(t){case`amount`:return e.amount;case`created_at`:return e.created_at;case`status`:return e.status}},r),[e.credit_notes,t,r]);return z(J,{title:`Credit Notes`,count:e.total,scope:e.scope,columns:[{key:`number`,header:`Number`,className:`font-mono text-xs`,render:e=>e.credit_note_number||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-secondary font-mono text-xs`,render:e=>W(e.customer_id,10)},{key:`invoice`,header:`Invoice`,className:`text-secondary font-mono text-xs`,render:e=>W(e.invoice_id,10)},{key:`status`,header:`Status`,sortable:!0,render:e=>z(q,{status:e.status})},{key:`amount`,header:`Amount`,sortable:!0,align:`right`,className:`text-destructive`,render:e=>U(e.amount,e.currency||a)},{key:`repayment`,header:`Repayment`,className:`text-xs`,render:e=>e.repayment_method||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)}],rows:o,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},emptyMessage:`No credit notes match.`,rowKey:(e,t)=>e.id||t,hoverRows:!1})}function Lt({payload:e}){let t=e.customer,n=t.address||{},r=[n.line1,n.line2,n.city,n.state,n.zipCode||n.zip_code,n.country].filter(Boolean).join(`, `),i=t.ship_to_address||{},a=[i.line1,i.line2,i.city,i.state,i.zipCode||i.zip_code,i.country].filter(Boolean).join(`, `);return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:t.name||z(B,{children:`—`})}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]})}),z(Rt,{children:[z($,{label:`External ID`,children:t.external_id?z(`span`,{className:`font-mono text-xs`,children:t.external_id}):z(B,{children:`—`})}),z($,{label:`Email`,children:t.email||z(B,{children:`—`})}),z($,{label:`Phone`,children:t.phone||z(B,{children:`—`})}),z($,{label:`Business Entity`,children:t.business_entity_name?z(`div`,{children:[z(`div`,{children:t.business_entity_name}),t.business_entity_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.business_entity_id}):null]}):t.business_entity_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.business_entity_id}):z(B,{children:`—`})}),z($,{label:`Created`,children:V(t.created_at)}),z($,{label:`Updated`,children:V(t.updated_at)})]}),r?z(Q,{title:`Primary Address`,children:z(`div`,{className:`text-sm`,children:r})}):null,a&&a!==r?z(Q,{title:`Ship-to Address`,children:z(`div`,{className:`text-sm`,children:a})}):null,t.communications_enabled!=null||t.auto_charge_enabled!=null?z(Q,{title:`Settings`,children:z(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[z(zt,{label:`Communications`,on:t.communications_enabled??null}),z(zt,{label:`Auto-charge`,on:t.auto_charge_enabled??null})]})}):null,t.default_payment_method?z(Q,{title:`Payment Method`,children:z(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(`span`,{className:`bg-muted rounded px-2 py-0.5 text-xs`,children:(t.default_payment_method.type||`unknown`).replace(/_/g,` `)}),t.default_payment_method.brand?z(`span`,{children:t.default_payment_method.brand}):null,t.default_payment_method.last4?z(`span`,{className:`font-mono`,children:[`•••• `,t.default_payment_method.last4]}):null,t.default_payment_method.connector_name?z(`span`,{className:`text-muted-foreground text-xs`,children:[`via `,t.default_payment_method.connector_name]}):null]})}):null,t.tax_info&&t.tax_info.length>0?z(Q,{title:`Tax Info`,children:z(`div`,{className:`space-y-1`,children:t.tax_info.map((e,t)=>z(`div`,{className:`flex gap-3 text-sm`,children:[e.tax_code?z(`span`,{className:`bg-muted rounded px-2 py-0.5 text-xs`,children:e.tax_code}):null,e.tax_id?z(`span`,{className:`font-mono text-xs`,children:e.tax_id}):null,e.country_code?z(`span`,{className:`text-muted-foreground text-xs`,children:e.country_code}):null]},t))})}):null,t.contacts&&t.contacts.length>0?z(Q,{title:`Contacts (${t.contacts.length})`,children:z(`div`,{className:`space-y-2`,children:t.contacts.map((e,t)=>z(`div`,{className:`border-border flex items-center justify-between rounded border px-3 py-2`,children:[z(`div`,{children:[z(`div`,{className:`text-sm font-medium`,children:e.name||z(B,{children:`—`})}),e.email?z(`div`,{className:`text-muted-foreground text-xs`,children:e.email}):null]}),z(`div`,{className:`flex gap-2`,children:[e.send_invoice?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`invoice`}):null,e.send_contract?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`contract`}):null]})]},t))})}):null,t.custom_data&&Object.keys(t.custom_data).length>0?z(Q,{title:`Custom Data`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_data).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function Rt({children:e}){return z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:e})}function zt({label:e,on:t}){return t===null?null:z(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${t?`bg-secondary/20 text-secondary ring-1 ring-secondary/30`:`bg-muted text-muted-foreground ring-1 ring-border`}`,children:[e,`: `,t?`on`:`off`]})}function Bt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.customers,e=>t===`name`?e.name:e.created_at??null,r),[e.customers,t,r]);return z(J,{title:`Customers`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`external_id`,header:`External ID`,className:`font-mono text-xs`,render:e=>e.external_id||z(B,{children:`—`})},{key:`email`,header:`Email`,className:`text-secondary`,render:e=>e.email||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/customers/${e.id}/view`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No customers match.`,rowKey:(e,t)=>e.id||t})}function Vt({payload:e}){return z(J,{title:`Entitlements`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Entitlement`,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`entitlement_type`,header:`Type`,className:`text-xs`,render:e=>e.entitlement_type||z(B,{children:`—`})},{key:`units`,header:`Units`,className:`font-mono text-xs`,render:e=>e.units||z(B,{children:`—`})},{key:`product_name`,header:`Product`,className:`text-xs`,render:e=>e.product_name||z(B,{children:`—`})},{key:`is_active`,header:`Status`,className:`text-xs`,render:e=>e.is_active==null?z(B,{children:`—`}):e.is_active?`active`:`inactive`},{key:`created_at`,header:`Created`,className:`whitespace-nowrap`,render:e=>V(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/entitlements/${e.id}/edit`})}],rows:e.entitlements,emptyMessage:`No entitlements match.`,rowKey:(e,t)=>e.id||t})}function Ht({payload:e}){return z(J,{title:`Business Entities`,count:e.total,columns:[{key:`name`,header:`Name`,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`email`,header:`Email`,className:`text-secondary text-xs`,render:e=>e.email||z(B,{children:`—`})},{key:`phone`,header:`Phone`,className:`font-mono text-xs`,render:e=>e.phone_number||z(B,{children:`—`})},{key:`country`,header:`Country`,className:`text-xs`,render:e=>e.country||z(B,{children:`—`})},{key:`default`,header:`Default`,className:`text-xs`,render:e=>e.is_default==null?z(B,{children:`—`}):e.is_default?`yes`:`no`},{key:`view`,header:`View`,render:e=>z(Y,{href:`/settings/tax-configuration/entity/${e.id}`})}],rows:e.entities,emptyMessage:`No business entities to show.`,rightHint:null,rowKey:(e,t)=>e.id||t})}function Ut({payload:e}){let t=e.invoice,n=t.currency||`USD`,r=t.due_date&&t.amount_due&&t.amount_due>0?_t(t.due_date):null,i=r!=null&&r>0;return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:[z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[z(`span`,{className:`font-mono`,children:t.invoice_number||t.id}),t.status?z(q,{status:t.status}):null,i?z(`span`,{className:`bg-destructive/20 text-destructive ring-destructive/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:[r,`d overdue`]}):null]}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]}),z(`div`,{className:`flex gap-2`,children:[t.invoice_pdf?z(Wt,{href:t.invoice_pdf,children:`PDF`}):null,t.payment_url?z(Wt,{href:t.payment_url,children:`Payment link`}):null]})]}),z(`div`,{className:`border-border grid grid-cols-2 gap-3 rounded-md border p-3 sm:grid-cols-4`,children:[z(Z,{label:`Total`,value:U(t.invoice_total,n)}),z(Z,{label:`Paid`,value:U(t.paid_amount,n)}),z(Z,{label:`Due`,value:U(t.amount_due,n),tone:i?`warn`:void 0}),z(Z,{label:`Period`,value:t.invoice_period_begin&&t.invoice_period_end?z(`span`,{className:`text-sm`,children:[t.invoice_period_begin.slice(0,10),` →`,` `,t.invoice_period_end.slice(0,10)]}):z(B,{children:`—`})})]}),z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:[z($,{label:`Customer`,children:t.customer_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.customer_name}),t.customer_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.customer_id}):null]}):t.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.customer_id}):z(B,{children:`—`})}),z($,{label:`Business Entity`,children:t.business_entity_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.business_entity_id}):z(B,{children:`—`})}),z($,{label:`Contract`,children:t.contract_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.contract_name}),t.contract_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.contract_id}):null]}):t.contract_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.contract_id}):z(B,{children:`—`})}),z($,{label:`External ID`,children:t.external_id?z(`span`,{className:`font-mono text-xs`,children:t.external_id}):z(B,{children:`—`})}),z($,{label:`Created`,children:H(t.created_at)}),z($,{label:`Due Date`,children:V(t.due_date)}),z($,{label:`Currency`,children:n})]}),t.notes?z(Q,{title:`Notes`,children:z(`div`,{className:`max-w-prose text-sm`,children:t.notes})}):null,t.approved_at||t.sent_at||t.paid_at?z(Q,{title:`Timeline`,children:z(`div`,{className:`flex flex-wrap gap-4 text-sm`,children:[t.sent_at?z(`div`,{children:[z(`span`,{className:`text-muted-foreground text-xs`,children:`Sent `}),z(`span`,{className:`tabular-nums`,children:H(t.sent_at)})]}):null,t.approved_at?z(`div`,{children:[z(`span`,{className:`text-muted-foreground text-xs`,children:`Approved `}),z(`span`,{className:`tabular-nums`,children:H(t.approved_at)})]}):null,t.paid_at?z(`div`,{children:[z(`span`,{className:`text-muted-foreground text-xs`,children:`Paid `}),z(`span`,{className:`tabular-nums`,children:H(t.paid_at)})]}):null]})}):null,t.custom_data&&Object.keys(t.custom_data).length>0?z(Q,{title:`Custom Data`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_data).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function Wt({children:e,href:t}){return z(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`border-border bg-accent text-accent-foreground hover:bg-primary hover:text-primary-foreground rounded border px-3 py-1 text-xs transition-colors`,children:e})}function Gt({payload:e}){let t=Ee(null),[n,r]=I(400),[i,a]=I(!1);return Te(()=>{if(!(!t.current||!i))try{let e=t.current.contentDocument;if(e?.documentElement){let t=e.documentElement.scrollHeight;t>0&&r(Math.min(t+16,2e3))}}catch{}},[i,e.html]),e.html?z(`div`,{className:`space-y-2`,children:[e.invoice_id?z(`header`,{className:`flex items-baseline gap-2`,children:[z(`h2`,{className:`m-0 text-lg font-semibold`,children:`Invoice Preview`}),z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:e.invoice_id})]}):null,z(`div`,{className:`border-border overflow-hidden rounded-md border`,children:z(`iframe`,{ref:t,title:`Invoice preview`,srcDoc:e.html,onLoad:()=>a(!0),style:{width:`100%`,height:`${n}px`,border:`none`,background:`#fff`},sandbox:`allow-same-origin`})})]}):z(`div`,{className:`text-muted-foreground border-border rounded-md border py-8 text-center`,children:`No preview generated for this invoice yet.`})}function Kt({payload:e}){let t=e.currency||`USD`,n=e.lines||[];return z(J,{title:z(S,{children:[`Line Items`,` `,z(`span`,{className:`text-muted-foreground font-normal`,children:[`(`,n.length,`)`]}),e.invoice_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:[` `,`· `,e.invoice_id]}):null]}),rightHint:e.total==null?null:z(`span`,{className:`text-sm`,children:[`Total:`,` `,z(`span`,{className:`font-medium tabular-nums`,children:U(e.total,t)})]}),columns:[{key:`type`,header:`Type`,className:`text-muted-foreground text-xs`,render:e=>z(`div`,{className:`flex items-center gap-1`,children:[e.line_item_type?e.line_item_type.replace(/_/g,` `):z(B,{children:`—`}),e.is_adjustment?z(`span`,{className:`bg-warning/15 text-warning ring-warning/30 rounded-full px-1.5 py-0.5 text-[10px] ring-1`,children:e.adjustment_type||`adj`}):null]})},{key:`item`,header:`Item`,render:e=>z(S,{children:[z(`div`,{className:`font-medium`,children:e.name||z(B,{children:`—`})}),e.description?z(`div`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{key:`pricing_model`,header:`Pricing Model`,className:`text-muted-foreground text-xs`,render:e=>e.pricing_model||z(B,{children:`—`})},{key:`qty`,header:`Qty`,align:`right`,render:e=>e.quantity?.display||(e.quantity?.value??z(B,{children:`—`}))},{key:`price`,header:`Price`,align:`right`,render:e=>e.price?vt(e.price):z(B,{children:`—`})},{key:`subtotal`,header:`Subtotal`,align:`right`,render:e=>z(`span`,{className:e.subtotal?.value!=null&&e.subtotal.value<0?`text-destructive`:``,children:vt(e.subtotal)})},{key:`period`,header:`Service Period`,className:`text-xs whitespace-nowrap`,render:e=>e.service_start_date&&e.service_end_date?z(S,{children:[V(e.service_start_date),` → `,V(e.service_end_date)]}):z(B,{children:`—`})},{key:`billed`,header:`Billed`,className:`text-xs`,render:e=>e.is_billed===!0?`✓`:e.is_billed===!1?`—`:z(B,{children:`?`})}],rows:n,emptyMessage:`No line items on this invoice.`,hoverRows:!1})}function qt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=e.default_currency||`USD`,o=L(()=>X(e.invoices,e=>{switch(t){case`invoice_number`:return e.invoice_number;case`invoice_total`:return e.invoice_total;case`amount_due`:return e.amount_due;case`due_date`:return e.due_date;case`created_at`:return e.created_at}},r),[e.invoices,t,r]),s=e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},c=e=>{if(!e.due_date||!e.amount_due||e.amount_due<=0)return null;let t=_t(e.due_date);return t!=null&&t>0?t:null};return z(J,{title:`Invoices`,count:e.total,scope:e.scope,columns:[{key:`invoice_number`,header:`Invoice`,sortable:!0,className:`font-mono text-xs`,render:e=>e.invoice_number||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-secondary font-mono text-xs`,render:e=>W(e.customer_id,10)},{key:`period`,header:`Period`,className:`text-xs whitespace-nowrap`,render:e=>e.invoice_period_begin&&e.invoice_period_end?`${e.invoice_period_begin.slice(0,10)} → ${e.invoice_period_end.slice(0,10)}`:z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`invoice_total`,header:`Total`,sortable:!0,align:`right`,render:e=>U(e.invoice_total,a)},{key:`amount_due`,header:`Due`,sortable:!0,align:`right`,render:e=>z(`span`,{className:c(e)==null?``:`text-destructive font-medium`,children:U(e.amount_due,a)})},{key:`due_date`,header:`Due Date`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.due_date)},{key:`overdue`,header:`Overdue`,align:`right`,render:e=>{let t=c(e);return t==null?z(`span`,{className:`text-muted-foreground`,children:z(B,{children:`—`})}):z(`span`,{className:`text-destructive font-medium`,children:[t,`d`]})}},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/invoices/${e.id}/view`})}],rows:o,sortKey:t,sortDir:r,onSort:s,emptyMessage:`No invoices match.`,rowKey:(e,t)=>e.id||t})}function Jt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.jobs,e=>{switch(t){case`name`:return e.name;case`created_at`:return e.created_at;case`status`:return e.status}},r),[e.jobs,t,r]),o=e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},s=e.status_counts||{},c=z(`div`,{className:`flex flex-wrap gap-1.5 text-xs`,children:Object.entries(s).map(([e,t])=>z(`span`,{className:`bg-muted rounded-full px-2 py-0.5`,children:[e,`: `,z(`span`,{className:`font-medium tabular-nums`,children:t})]},e))});return z(J,{title:`Jobs`,count:e.total,rightHint:c,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`type`,header:`Type`,className:`text-xs`,render:e=>e.job_type||z(B,{children:`—`})},{key:`resource`,header:`Resource`,className:`text-xs`,render:e=>e.resource||z(B,{children:`—`})},{key:`status`,header:`Status`,sortable:!0,render:e=>z(q,{status:e.status})},{key:`description`,header:`Description`,className:`text-muted-foreground max-w-xs truncate text-xs`,render:e=>e.description||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`text-xs whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/jobs/${e.id}/view`})}],rows:a,sortKey:t,sortDir:r,onSort:o,emptyMessage:`No jobs match.`,rowKey:(e,t)=>e.id||t})}function Yt({payload:e}){let t=e.default_currency||`USD`,n=e.entries,r=L(()=>{let e=0,t=0;for(let r of n)Number.isFinite(r.total_debit)&&(e+=r.total_debit),Number.isFinite(r.total_credit)&&(t+=r.total_credit);return{d:e,c:t}},[n]),i=z(S,{children:[`Σ debit `,U(r.d,t),` · Σ credit `,U(r.c,t)]});return z(J,{title:`Journal Entries`,count:e.total,scope:e.scope,rightHint:i,columns:[{key:`posted_at`,header:`Posted`,className:`whitespace-nowrap`,render:e=>H(e.posted_at)},{key:`event`,header:`Event`,className:`text-xs`,render:e=>e.event||z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status_type})},{key:`lines`,header:`Lines`,align:`right`,render:e=>e.line_count??z(B,{children:`—`})},{key:`total_debit`,header:`Σ Debit`,align:`right`,render:e=>e.total_debit==null?z(B,{children:`—`}):U(e.total_debit,e.currency||t)},{key:`total_credit`,header:`Σ Credit`,align:`right`,render:e=>e.total_credit==null?z(B,{children:`—`}):U(e.total_credit,e.currency||t)},{key:`description`,header:`Description`,className:`text-muted-foreground max-w-xs truncate text-xs`,render:e=>e.description||z(B,{children:`—`})}],rows:n,emptyMessage:`No entries match.`,rowKey:(e,t)=>e.id||t,hoverRows:!1})}function Xt({payload:e}){let t=e.payment_methods||[];return z(`div`,{className:`space-y-3`,children:[z(`header`,{className:`flex items-baseline justify-between gap-3`,children:z(`h2`,{className:`m-0 text-lg font-semibold`,children:[`Payment Methods`,` `,z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[`(`,t.length,`)`]}),e.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:[` `,`· `,e.customer_id]}):null]})}),t.length===0?z(`div`,{className:`text-muted-foreground border-border rounded-md border py-8 text-center`,children:`No payment methods saved.`}):z(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:t.map((e,t)=>z(Zt,{method:e},e.id||t))})]})}function Zt({method:e}){let t=(e.type||``).toLowerCase().includes(`card`);return z(`article`,{className:`space-y-1 rounded-md border p-3 ${e.is_default?`border-ring ring-ring ring-1`:`border-border`}`,children:[z(`header`,{className:`flex items-baseline justify-between gap-2`,children:[z(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[z(`span`,{className:`bg-muted rounded px-2 py-0.5 text-xs`,children:(e.type||`unknown`).replace(/_/g,` `)}),e.brand?z(`span`,{className:`text-muted-foreground`,children:e.brand}):null,e.connector_name?z(`span`,{className:`text-muted-foreground text-xs`,children:[`via `,e.connector_name]}):null]}),e.is_default?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`default`}):null]}),z(`div`,{className:`font-mono text-sm`,children:e.last4?`•••• ${e.last4}`:z(B,{children:`—`})}),z(`div`,{className:`text-muted-foreground flex gap-3 text-xs`,children:[e.status?z(`span`,{className:`rounded-full px-2 py-0.5 text-xs ring-1 ${e.status===`valid`?`bg-secondary/20 text-secondary ring-secondary/30`:`bg-destructive/20 text-destructive ring-destructive/30`}`,children:e.status}):null,t&&e.exp_month&&e.exp_year?z(`span`,{children:[`exp `,String(e.exp_month).padStart(2,`0`),`/`,String(e.exp_year).slice(-2)]}):null,e.created_at?z(`span`,{children:[`added `,V(e.created_at)]}):null]})]})}var Qt={payment:`bg-secondary/20 text-secondary ring-1 ring-secondary/30`,refund:`bg-accent text-accent-foreground ring-1 ring-border`,payment_reversal:`bg-destructive/20 text-destructive ring-1 ring-destructive/30`,authorization:`bg-primary/20 text-primary ring-1 ring-primary/30`,tax_withheld:`bg-muted text-muted-foreground ring-1 ring-border`},$t=`bg-muted text-muted-foreground ring-1 ring-border`;function en({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=e.default_currency||`USD`,o=L(()=>X(e.payments,e=>{switch(t){case`amount`:return e.amount;case`payment_date`:return e.payment_date;case`created_at`:return e.created_at;case`type`:return e.type}},r),[e.payments,t,r]);return z(J,{title:`Payments`,count:e.total,scope:e.scope,columns:[{key:`external_id`,header:`External ID`,className:`font-mono text-xs`,render:e=>e.external_id||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-secondary font-mono text-xs`,render:e=>W(e.customer_id,10)},{key:`invoice`,header:`Invoice`,className:`text-secondary font-mono text-xs`,render:e=>W(e.invoice_id,10)},{key:`type`,header:`Type`,sortable:!0,render:e=>e.type?z(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs ${Qt[e.type]||$t}`,children:e.type}):z(B,{children:`—`})},{key:`method`,header:`Method`,className:`text-xs`,render:e=>e.payment_method||z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`amount`,header:`Amount`,sortable:!0,align:`right`,render:e=>{let t=e.amount!=null&&e.amount<0,n=e.type===`refund`||e.type===`payment_reversal`;return z(`span`,{className:t||n?`text-destructive`:``,children:U(e.amount,e.currency||a)})}},{key:`payment_date`,header:`Date`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.payment_date)},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)}],rows:o,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},emptyMessage:`No payments match.`,rowKey:(e,t)=>e.id||t,hoverRows:!1})}function tn({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.plans,e=>t===`name`?e.name:e.created_at,r),[e.plans,t,r]);return z(J,{title:`Plans`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`description`,header:`Description`,className:`text-muted-foreground text-xs`,render:e=>e.description||z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`plan_version`,header:`Version`,align:`right`,render:e=>e.plan_version??z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/plansv2/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No plans match.`,rowKey:(e,t)=>e.id||t})}function nn({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.products,e=>t===`name`?e.name:e.created_at,r),[e.products,t,r]);return z(J,{title:`Products`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`sku`,header:`SKU`,className:`font-mono text-xs`,render:e=>e.sku||z(B,{children:`—`})},{key:`type`,header:`Type`,className:`text-xs`,render:e=>e.product_type||z(B,{children:`—`})},{key:`active`,header:`Active`,className:`text-xs`,render:e=>e.is_active==null?z(B,{children:`—`}):e.is_active?`yes`:`no`},{key:`description`,header:`Description`,className:`text-muted-foreground text-xs`,render:e=>e.description||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/products/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No products match.`,rowKey:(e,t)=>e.id||t})}function rn({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.raw_metrics,e=>t===`name`?e.name:e.created_at,r),[e.raw_metrics,t,r]);return z(J,{title:`Raw Metrics`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`api_slug`,header:`API Slug`,className:`font-mono text-xs`,render:e=>e.api_slug||z(B,{children:`—`})},{key:`upload`,header:`Upload Enabled`,className:`text-xs`,render:e=>e.usage_upload_enabled==null?z(B,{children:`—`}):e.usage_upload_enabled?`yes`:`no`},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/meters/raw-metrics/${e.id}/view`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No raw metrics match.`,rowKey:(e,t)=>e.id||t})}var an={name:`Zenskar`,version:`1.0.0`},on=`2026-01-26`,sn={listCustomers:{fallback:{customers:[],total:0},marker:`customer-table:mounted`,render:e=>z(Bt,{payload:e})},listInvoices:{fallback:{invoices:[],total:0},marker:`invoice-table:mounted`,render:e=>z(qt,{payload:e})},getInvoiceLineItems:{fallback:{lines:[]},marker:`invoice-line-items:mounted`,render:e=>z(Kt,{payload:e})},listAllPayments:{fallback:{payments:[],total:0},marker:`payment-table:mounted`,render:e=>z(en,{payload:e})},listCreditNotes:{fallback:{credit_notes:[],total:0},marker:`credit-note-table:mounted`,render:e=>z(It,{payload:e})},listContracts:{fallback:{contracts:[],total:0},marker:`contract-table:mounted`,render:e=>z(Pt,{payload:e})},getCustomerById:{fallback:{customer:{id:``}},marker:`customer-detail:mounted`,render:e=>z(Lt,{payload:e})},getInvoiceById:{fallback:{invoice:{id:``}},marker:`invoice-detail:mounted`,render:e=>z(Ut,{payload:e})},getContractById:{fallback:{contract:{id:``},phases:[]},marker:`contract-detail:mounted`,render:e=>z(Mt,{payload:e})},getCreditNoteById:{fallback:{credit_note:{id:``}},marker:`credit-note-detail:mounted`,render:e=>z(Ft,{payload:e})},listProducts:{fallback:{products:[],total:0},marker:`product-table:mounted`,render:e=>z(nn,{payload:e})},listPlans:{fallback:{plans:[],total:0},marker:`plan-table:mounted`,render:e=>z(tn,{payload:e})},listJournalEntries:{fallback:{entries:[],total:0},marker:`journal-table:mounted`,render:e=>z(Yt,{payload:e})},listJobs:{fallback:{jobs:[],total:0},marker:`job-table:mounted`,render:e=>z(Jt,{payload:e})},listContacts:{fallback:{contacts:[],total:0},marker:`contact-table:mounted`,render:e=>z(At,{payload:e})},listRawMetrics:{fallback:{raw_metrics:[],total:0},marker:`raw-metric-table:mounted`,render:e=>z(rn,{payload:e})},listAggregates:{fallback:{aggregates:[],total:0},marker:`aggregate-table:mounted`,render:e=>z(kt,{payload:e})},listCustomerAddresses:{fallback:{addresses:[]},marker:`address-list:mounted`,render:e=>z(Et,{payload:e})},listPaymentMethods:{fallback:{payment_methods:[]},marker:`payment-method-list:mounted`,render:e=>z(Xt,{payload:e})},listBusinessEntities:{fallback:{entities:[]},marker:`entity-table:mounted`,render:e=>z(Ht,{payload:e})},listEntitlements:{fallback:{entitlements:[],total:0},marker:`entitlement-table:mounted`,render:e=>z(Vt,{payload:e})},getInvoicePreviewHtml:{fallback:{html:``},marker:`invoice-preview:mounted`,render:e=>z(Gt,{payload:e})}};function cn(){return typeof window>`u`?null:window.openai??null}function ln(){let e=cn(),[t,n]=I(e?.toolInput?.toolName??null),[r,i]=I(e?.toolOutput??null),a=Ee(null);if(Te(()=>{let e=ft(`ui/notifications/tool-result`,e=>{let t=e;t&&Object.prototype.hasOwnProperty.call(t,`structuredContent`)&&i(t.structuredContent??null)}),t=ft(`ui/notifications/host-context-changed`,e=>{let t=e?.toolInfo?.tool?.name;typeof t==`string`&&n(t)});return ct(`ui/initialize`,{appCapabilities:{},appInfo:an,protocolVersion:on}).then(e=>{let t=e?.hostContext?.toolInfo?.tool?.name;typeof t==`string`&&n(t),lt(`ui/notifications/initialized`)}).catch(()=>{}),()=>{e(),t()}},[]),Te(()=>{let e=e=>{let t=e?.detail?.globals;t&&(t.toolInput?.toolName&&n(t.toolInput.toolName),Object.prototype.hasOwnProperty.call(t,`toolOutput`)&&i(t.toolOutput??null))};return window.addEventListener(`openai:set_globals`,e,{passive:!0}),()=>{window.removeEventListener(`openai:set_globals`,e)}},[]),Te(()=>{if(r===null||!t)return;let e=sn[t];if(e?.marker&<(`ui/message`,{hidden:!0,marker:e.marker}),!a.current)return;let n=()=>{let e=a.current.getBoundingClientRect();lt(`ui/notifications/size-changed`,{width:Math.round(e.width),height:Math.round(e.height)})};n();let i=new ResizeObserver(n);return i.observe(a.current),()=>i.disconnect()},[r,t]),!t||!sn[t])return z(`div`,{"data-app-loading":!0,style:{visibility:`hidden`,minHeight:1}});let o=sn[t];if(r===null&&!e?.toolOutput)return z(`div`,{"data-app-loading":!0,style:{visibility:`hidden`,minHeight:1}});let s=r??o.fallback;return z(`div`,{ref:a,className:`text-foreground bg-background p-4 font-sans text-[14px]`,children:o.render(s)})}var un=document.getElementById(`root`);un&&at(un).render(z(S,{children:z(ln,{})}));</script>
|
|
7
|
+
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e,t,n,r,i,a,o,s,c,l,u,d,f,p,m={},h=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,_=Array.isArray;function v(e,t){for(var n in t)e[n]=t[n];return e}function y(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,r){var i,a,o,s={};for(o in n)o==`key`?i=n[o]:o==`ref`?a=n[o]:s[o]=n[o];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):r),typeof t==`function`&&t.defaultProps!=null)for(o in t.defaultProps)s[o]===void 0&&(s[o]=t.defaultProps[o]);return x(t,s,i,a,null)}function x(e,r,i,a,o){var s={type:e,props:r,key:i,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++n,__i:-1,__u:0};return o==null&&t.vnode!=null&&t.vnode(s),s}function S(e){return e.children}function C(e,t){this.props=e,this.context=t}function w(e,t){if(t==null)return e.__?w(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?w(e):null}function T(e){if(e.__P&&e.__d){var n=e.__v,r=n.__e,i=[],a=[],o=v({},n);o.__v=n.__v+1,t.vnode&&t.vnode(o),ie(e.__P,o,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,i,r??w(n),!!(32&n.__u),a),o.__v=n.__v,o.__.__k[o.__i]=o,oe(i,o,a),n.__e=n.__=null,o.__e!=r&&E(o)}}function E(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),E(e)}function D(e){(!e.__d&&(e.__d=!0)&&r.push(e)&&!O.__r++||i!=t.debounceRendering)&&((i=t.debounceRendering)||a)(O)}function O(){try{for(var e,t=1;r.length;)r.length>t&&r.sort(o),e=r.shift(),t=r.length,T(e)}finally{r.length=O.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,g,_,v,y,b=r&&r.__k||h,x=t.length;for(c=te(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||m,p.__i=d,v=ie(e,p,f,i,a,o,s,c,l,u),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&le(f.ref,null,p),u.push(p.ref,p.__c||g,p)),_==null&&g!=null&&(_=g),(y=!!(4&p.__u))||f.__k===p.__k?(c=k(p,c,e,y),y&&f.__e&&(f.__e=null)):typeof p.type==`function`&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return n.__e=_,c}function te(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=x(null,o,null,null,null):_(o)?o=e.__k[a]=x(S,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=x(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=j(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=w(s)),ue(s,s));return r}function k(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=k(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=w(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function A(e,t){return t||=[],e==null||typeof e==`boolean`||(_(e)?e.some(function(e){A(e,t)}):t.push(e)),t}function j(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ne(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||g.test(t)?n:n+`px`}function M(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ne(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(u,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[l]=r[l]:(n[l]=d,e.addEventListener(t,a?p:f,a)):e.removeEventListener(t,a?p:f,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function re(e){return function(n){if(this.l){var r=this.l[n.type+e];if(n[c]==null)n[c]=d++;else if(n[c]<r[l])return;return r(t.event?t.event(n):n)}}}function ie(e,n,r,i,a,o,s,c,l,u){var d,f,p,m,g,b,x,w,T,E,D,O,te,k,A,j=n.type;if(n.constructor!==void 0)return null;128&r.__u&&(l=!!(32&r.__u),o=[c=n.__e=r.__e]),(d=t.__b)&&d(n);n:if(typeof j==`function`)try{if(w=n.props,T=j.prototype&&j.prototype.render,E=(d=j.contextType)&&i[d.__c],D=d?E?E.props.value:d.__:i,r.__c?x=(f=n.__c=r.__c).__=f.__E:(T?n.__c=f=new j(w,D):(n.__c=f=new C(w,D),f.constructor=j,f.render=de),E&&E.sub(f),f.state||={},f.__n=i,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&j.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=v({},f.__s)),v(f.__s,j.getDerivedStateFromProps(w,f.__s))),m=f.props,g=f.state,f.__v=n,p)T&&j.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&j.getDerivedStateFromProps==null&&w!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(w,D),n.__v==r.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(w,f.__s,D)){n.__v!=r.__v&&(f.props=w,f.state=f.__s,f.__d=!1),n.__e=r.__e,n.__k=r.__k,n.__k.some(function(e){e&&(e.__=n)}),h.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(w,f.__s,D),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,g,b)})}if(f.context=D,f.props=w,f.__P=e,f.__e=!1,O=t.__r,te=0,T)f.state=f.__s,f.__d=!1,O&&O(n),d=f.render(f.props,f.state,f.context),h.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,O&&O(n),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++te<25);f.state=f.__s,f.getChildContext!=null&&(i=v(v({},i),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(b=f.getSnapshotBeforeUpdate(m,g)),k=d!=null&&d.type===S&&d.key==null?se(d.props.children):d,c=ee(e,_(k)?k:[k],n,r,i,a,o,s,c,l,u),f.base=n.__e,n.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(n.__v=null,l||o!=null)if(e.then){for(n.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,n.__e=c}else{for(A=o.length;A--;)y(o[A]);ae(n)}else n.__e=r.__e,n.__k=r.__k,e.then||ae(n);t.__e(e,n,r)}else o==null&&n.__v==r.__v?(n.__k=r.__k,n.__e=r.__e):c=n.__e=ce(r.__e,n,r,i,a,o,s,l,u);return(d=t.diffed)&&d(n),128&n.__u?void 0:c}function ae(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ae))}function oe(e,n,r){for(var i=0;i<r.length;i++)le(r[i],r[++i],r[++i]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function se(e){return typeof e!=`object`||!e||e.__b>0?e:_(e)?e.map(se):e.constructor===void 0?v({},e):null}function ce(n,r,i,a,o,s,c,l,u){var d,f,p,h,g,v,b,x=i.props||m,S=r.props,C=r.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){n=g,s[d]=null;break}}if(n==null){if(C==null)return document.createTextNode(S);n=document.createElementNS(o,C,S.is&&S),l&&=(t.__m&&t.__m(r,s),!1),s=null}if(C==null)x===S||l&&n.data==S||(n.data=S);else{if(s=C==`textarea`&&S.defaultValue!=null?null:s&&e.call(n.childNodes),!l&&s!=null)for(x={},d=0;d<n.attributes.length;d++)x[(g=n.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||M(n,d,null,g,o);for(d in S)g=S[d],d==`children`?h=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?v=g:d==`checked`?b=g:l&&typeof g!=`function`||x[d]===g||M(n,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==n.innerHTML)||(n.innerHTML=f.__html),r.__k=[];else if(p&&(n.innerHTML=``),ee(r.type==`template`?n.content:n,_(h)?h:[h],r,i,a,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&w(i,0),l,u),s!=null)for(d=s.length;d--;)y(s[d]);l&&C!=`textarea`||(d=`value`,C==`progress`&&v==null?n.removeAttribute(`value`):v!=null&&(v!==n[d]||C==`progress`&&!v||C==`option`&&v!=x[d])&&M(n,d,v,x[d],o),d=`checked`,b!=null&&b!=n[d]&&M(n,d,b,x[d],o))}return n}function le(e,n,r){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&n==null||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,r)}}function ue(e,n,r){var i,a;if(t.unmount&&t.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||le(i,null,n)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){t.__e(e,n)}i.base=i.__P=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&ue(i[a],n,r||typeof e.type!=`function`);r||y(e.__e),e.__c=e.__=e.__e=void 0}function de(e,t,n){return this.constructor(e,n)}function fe(n,r,i){var a,o,s,c;r==document&&(r=document.documentElement),t.__&&t.__(n,r),o=(a=typeof i==`function`)?null:i&&i.__k||r.__k,s=[],c=[],ie(r,n=(!a&&i||r).__k=b(S,null,[n]),o||m,m,r.namespaceURI,!a&&i?[i]:o?null:r.firstChild?e.call(r.childNodes):null,s,!a&&i?i:o?o.__e:r.firstChild,a,c),oe(s,n,c)}e=h.slice,t={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},n=0,C.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=v({},this.state);typeof e==`function`&&(e=e(v({},n),this.props)),e&&v(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),D(this))},C.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),D(this))},C.prototype.render=S,r=[],a=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,o=function(e,t){return e.__v.__b-t.__v.__b},O.__r=0,s=Math.random().toString(8),c=`__d`+s,l=`__a`+s,u=/(PointerCapture)$|Capture$/i,d=0,f=re(!1),p=re(!0);var N,P,pe,me,he=0,ge=[],F=t,_e=F.__b,ve=F.__r,ye=F.diffed,be=F.__c,xe=F.unmount,Se=F.__;function Ce(e,t){F.__h&&F.__h(P,e,he||t),he=0;var n=P.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function I(e){return he=1,we(Ne,e)}function we(e,t,n){var r=Ce(N++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ne(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=P,!P.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};P.__f=!0;var a=P.shouldComponentUpdate,o=P.componentWillUpdate;P.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},P.shouldComponentUpdate=i}return r.__N||r.__}function Te(e,t){var n=Ce(N++,3);!F.__s&&Me(n.__H,t)&&(n.__=e,n.u=t,P.__H.__h.push(n))}function Ee(e){return he=5,L(function(){return{current:e}},[])}function L(e,t){var n=Ce(N++,7);return Me(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function De(){for(var e;e=ge.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Ae),t.__h.some(je),t.__h=[]}catch(n){t.__h=[],F.__e(n,e.__v)}}}F.__b=function(e){P=null,_e&&_e(e)},F.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Se&&Se(e,t)},F.__r=function(e){ve&&ve(e),N=0;var t=(P=e.__c).__H;t&&(pe===P?(t.__h=[],P.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Ae),t.__h.some(je),t.__h=[],N=0)),pe=P},F.diffed=function(e){ye&&ye(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ge.push(t)!==1&&me===F.requestAnimationFrame||((me=F.requestAnimationFrame)||ke)(De)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),pe=P=null},F.__c=function(e,t){t.some(function(e){try{e.__h.some(Ae),e.__h=e.__h.filter(function(e){return!e.__||je(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],F.__e(n,e.__v)}}),be&&be(e,t)},F.unmount=function(e){xe&&xe(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Ae(e)}catch(e){t=e}}),n.__H=void 0,t&&F.__e(t,n.__v))};var Oe=typeof requestAnimationFrame==`function`;function ke(e){var t,n=function(){clearTimeout(r),Oe&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Oe&&(t=requestAnimationFrame(n))}function Ae(e){var t=P,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),P=t}function je(e){var t=P;e.__c=e.__(),P=t}function Me(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ne(e,t){return typeof t==`function`?t(e):t}function Pe(e,t){for(var n in t)e[n]=t[n];return e}function Fe(e,t){for(var n in e)if(n!==`__source`&&!(n in t))return!0;for(var r in t)if(r!==`__source`&&e[r]!==t[r])return!0;return!1}function Ie(e,t){this.props=e,this.context=t}(Ie.prototype=new C).isPureReactComponent=!0,Ie.prototype.shouldComponentUpdate=function(e,t){return Fe(this.props,e)||Fe(this.state,t)};var Le=t.__b;t.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Le&&Le(e)},typeof Symbol<`u`&&Symbol.for;var Re=t.__e;t.__e=function(e,t,n,r){if(e.then){for(var i,a=t;a=a.__;)if((i=a.__c)&&i.__c)return t.__e??(t.__e=n.__e,t.__k=n.__k),i.__c(e,t)}Re(e,t,n,r)};var ze=t.unmount;function Be(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){typeof e.__c==`function`&&e.__c()}),e.__c.__H=null),(e=Pe({},e)).__c!=null&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return Be(e,t,n)})),e}function Ve(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ve(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function He(){this.__u=0,this.o=null,this.__b=null}function Ue(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function We(){this.i=null,this.l=null}t.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),ze&&ze(e)},(He.prototype=new C).__c=function(e,t){var n=t.__c,r=this;r.o??=[],r.o.push(n);var i=Ue(r.__v),a=!1,o=function(){a||r.__z||(a=!0,n.__R=null,i?i(c):c())};n.__R=o;var s=n.__P;n.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var e=r.state.__a;r.__v.__k[0]=Ve(e,e.__c.__P,e.__c.__O)}var t;for(r.setState({__a:r.__b=null});t=r.o.pop();)t.__P=s,t.forceUpdate()}};r.__u++||32&t.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(o,o)},He.prototype.componentWillUnmount=function(){this.o=[]},He.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement(`div`),r=this.__v.__k[0].__c;this.__v.__k[0]=Be(this.__b,n,r.__O=r.__P)}this.__b=null}var i=t.__a&&b(S,null,e.fallback);return i&&(i.__u&=-33),[b(S,null,t.__a?null:e.children),i]};var Ge=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!==`t`||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};(We.prototype=new C).__a=function(e){var t=this,n=Ue(t.__v),r=t.l.get(e);return r[0]++,function(i){var a=function(){t.props.revealOrder?(r.push(i),Ge(t,e,r)):i()};n?n(a):a()}},We.prototype.render=function(e){this.i=null,this.l=new Map;var t=A(e.children);e.revealOrder&&e.revealOrder[0]===`b`&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},We.prototype.componentDidUpdate=We.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ge(e,n,t)})};var Ke=typeof Symbol<`u`&&Symbol.for&&Symbol.for(`react.element`)||60103,qe=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Je=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ye=/[A-Z0-9]/g,Xe=typeof document<`u`,Ze=function(e){return(typeof Symbol<`u`&&typeof Symbol()==`symbol`?/fil|che|rad/:/fil|che|ra/).test(e)};function Qe(e,t,n){return t.__k??(t.textContent=``),fe(e,t),typeof n==`function`&&n(),e?e.__c:null}C.prototype.isReactComponent=!0,[`componentWillMount`,`componentWillReceiveProps`,`componentWillUpdate`].forEach(function(e){Object.defineProperty(C.prototype,e,{configurable:!0,get:function(){return this[`UNSAFE_`+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var $e=t.event;t.event=function(e){return $e&&(e=$e(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var et={configurable:!0,get:function(){return this.class}},tt=t.vnode;t.vnode=function(e){typeof e.type==`string`&&function(e){var t=e.props,n=e.type,r={},i=n.indexOf(`-`)==-1;for(var a in t){var o=t[a];if(!(a===`value`&&`defaultValue`in t&&o==null||Xe&&a===`children`&&n===`noscript`||a===`class`||a===`className`)){var s=a.toLowerCase();a===`defaultValue`&&`value`in t&&t.value==null?a=`value`:a===`download`&&!0===o?o=``:s===`translate`&&o===`no`?o=!1:s[0]===`o`&&s[1]===`n`?s===`ondoubleclick`?a=`ondblclick`:s!==`onchange`||n!==`input`&&n!==`textarea`||Ze(t.type)?s===`onfocus`?a=`onfocusin`:s===`onblur`?a=`onfocusout`:Je.test(a)&&(a=s):s=a=`oninput`:i&&qe.test(a)?a=a.replace(Ye,`-$&`).toLowerCase():o===null&&(o=void 0),s===`oninput`&&r[a=s]&&(a=`oninputCapture`),r[a]=o}}n==`select`&&(r.multiple&&Array.isArray(r.value)&&(r.value=A(t.children).forEach(function(e){e.props.selected=r.value.indexOf(e.props.value)!=-1})),r.defaultValue!=null&&(r.value=A(t.children).forEach(function(e){e.props.selected=r.multiple?r.defaultValue.indexOf(e.props.value)!=-1:r.defaultValue==e.props.value}))),t.class&&!t.className?(r.class=t.class,Object.defineProperty(r,`className`,et)):t.className&&(r.class=r.className=t.className),e.props=r}(e),e.$$typeof=Ke,tt&&tt(e)};var nt=t.__r;t.__r=function(e){nt&&nt(e),e.__c};var rt=t.diffed;t.diffed=function(e){rt&&rt(e);var t=e.props,n=e.__e;n!=null&&e.type===`textarea`&&`value`in t&&t.value!==n.value&&(n.value=t.value==null?``:t.value)};function it(e){return!!e.__k&&(fe(null,e),!0)}function at(e){return{render:function(t){Qe(t,e)},unmount:function(){it(e)}}}var R=new Map,ot=1,st=new Set;typeof window<`u`&&window.addEventListener(`message`,e=>{let t=e.data;if(!t||typeof t!=`object`||t.jsonrpc!==`2.0`)return;let n=t;if(n.id!=null&&R.has(n.id)){let e=R.get(n.id);R.delete(n.id),n.error?e.reject(n.error):e.resolve(n.result);return}if(n.method){let e={jsonrpc:`2.0`,method:n.method,params:n.params};st.forEach(t=>{try{t(e)}catch{}})}});function ct(e,t,n=3e4){if(typeof window>`u`||!window.parent)return Promise.reject(Error(`no host`));let r=ot++;return new Promise((i,a)=>{let o=setTimeout(()=>{R.has(r)&&(R.delete(r),a(Error(`callHost timeout: ${e}`)))},n);R.set(r,{resolve:e=>{clearTimeout(o),i(e)},reject:e=>{clearTimeout(o),a(e)}}),window.parent.postMessage({jsonrpc:`2.0`,id:r,method:e,params:t},`*`)})}function lt(e,t){typeof window>`u`||!window.parent||window.parent.postMessage({jsonrpc:`2.0`,method:e,params:t},`*`)}var ut=`https://app.zenskar.com`;function dt(e){let t=`${ut}${e.startsWith(`/`)?e:`/${e}`}`;ct(`ui/open-link`,{url:t}).catch(()=>{try{window.open(t,`_blank`,`noopener,noreferrer`)}catch{lt(`ui/message`,{text:`Open: ${t}`})}})}function ft(e,t){let n=n=>{n.method===e&&t(n.params)};return st.add(n),()=>st.delete(n)}var pt=0;Array.isArray;function z(e,n,r,i,a,o){n||={};var s,c,l=n;if(`ref`in l)for(c in l={},n)c==`ref`?s=n[c]:l[c]=n[c];var u={type:e,props:l,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--pt,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return t.vnode&&t.vnode(u),u}function B({children:e}){return z(`span`,{className:`text-muted-foreground`,children:e})}var mt=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function ht(e){if(!e)return null;let t=e.replace(` `,`T`);/^\d{4}-\d{2}-\d{2}$/.test(t)?t+=`T00:00:00Z`:/[zZ]|[+-]\d{2}:?\d{2}$/.test(t)||(t+=`Z`);let n=new Date(t);return Number.isNaN(n.getTime())?null:n}function gt(e){return e<10?`0`+e:String(e)}function V(e){let t=ht(e);return t?`${mt[t.getUTCMonth()]} ${gt(t.getUTCDate())}, ${t.getUTCFullYear()}`:z(B,{children:`—`})}function H(e){let t=ht(e);if(!t)return z(B,{children:`—`});let n=t.getUTCHours(),r=n>=12?`PM`:`AM`,i=n%12||12;return`${mt[t.getUTCMonth()]} ${gt(t.getUTCDate())}, ${t.getUTCFullYear()} ${gt(i)}:${gt(t.getUTCMinutes())} ${r}`}function _t(e,t=new Date){let n=ht(e);return n?Math.floor((t.getTime()-n.getTime())/864e5):null}function U(e,t=`USD`){if(e==null||!Number.isFinite(e))return z(B,{children:`—`});let n=e/100;try{return new Intl.NumberFormat(void 0,{style:`currency`,currency:t,maximumFractionDigits:2}).format(n)}catch{return`${t} ${n.toLocaleString()}`}}function vt(e){return e?e.display?e.display:e.value==null?z(B,{children:`—`}):U(e.value,e.unit||`USD`):z(B,{children:`—`})}function W(e,t=8){return e?e.length<=t?e:e.slice(0,t)+`…`:z(B,{children:`—`})}var G=`bg-secondary/20 text-secondary ring-1 ring-secondary/30`,yt=`bg-primary/20 text-primary ring-1 ring-primary/30`,bt=`bg-destructive/20 text-destructive ring-1 ring-destructive/30`,K=`bg-muted text-muted-foreground ring-1 ring-border`,xt=`bg-accent text-accent-foreground ring-1 ring-border`,St=`bg-secondary/12 text-secondary ring-1 ring-secondary/20`,Ct={paid:G,approved:G,active:G,success:G,posted:G,upcoming:yt,partially_paid:yt,in_progress:yt,paused:yt,failed:bt,disputed:bt,draft:K,void:K,voided:K,expired:K,archived:K,issued:St,scheduled:St,refunded:xt},wt=K;function q({status:e}){if(!e)return z(B,{children:`—`});let t=Ct[e.toLowerCase()]||wt,n=Tt(e);return z(`span`,{className:`inline-block whitespace-nowrap rounded-md px-2 py-0.5 text-xs ${t}`,children:n})}function Tt(e){let t=e.replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Et({payload:e}){let t=e.addresses||[];return z(`div`,{className:`space-y-3`,children:[z(`header`,{className:`flex items-baseline justify-between gap-3`,children:z(`h2`,{className:`m-0 text-lg font-semibold`,children:[`Addresses`,` `,z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[`(`,t.length,`)`]}),e.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:[` `,`· `,e.customer_id]}):null]})}),t.length===0?z(`div`,{className:`text-muted-foreground border-border rounded-md border py-8 text-center`,children:`No addresses on file.`}):z(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:t.map((e,t)=>z(Dt,{addr:e},e.id||t))})]})}function Dt({addr:e}){return z(`article`,{className:`space-y-1 rounded-md border p-3 ${e.is_primary?`border-ring ring-ring ring-1`:`border-border`}`,children:[z(`header`,{className:`flex items-baseline justify-between gap-2`,children:[z(`div`,{className:`text-sm font-medium`,children:e.label||z(B,{children:`Untitled`})}),e.is_primary?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`primary`}):null]}),z(`div`,{className:`text-sm`,children:[e.line1?z(`div`,{children:e.line1}):null,e.line2?z(`div`,{children:e.line2}):null,e.line3?z(`div`,{children:e.line3}):null,z(`div`,{children:[e.city,e.state,e.zip_code].filter(Boolean).join(`, `)||z(B,{children:`—`})}),e.country?z(`div`,{className:`text-muted-foreground mt-0.5 text-xs uppercase`,children:e.country}):null,e.validation_status?z(`span`,{className:`mt-1 inline-block rounded-full px-2 py-0.5 text-[10px] ring-1 ${e.validation_status===`valid`?`bg-secondary/20 text-secondary ring-secondary/30`:`bg-muted text-muted-foreground ring-border`}`,children:e.validation_status}):null]})]})}function J({title:e,count:t,scope:n,rightHint:r,columns:i,rows:a,sortKey:o,sortDir:s,onSort:c,emptyMessage:l=`Nothing to show.`,showIndex:u=!0,rowKey:d,rowClassName:f,hoverRows:p=!0}){let m=i.length+ +!!u,h=r===void 0&&c?`click headers to sort`:r;return z(`div`,{className:`space-y-3`,children:[z(`header`,{className:`flex items-baseline justify-between gap-3`,children:[z(`h2`,{className:`m-0 text-lg font-semibold`,children:[e,t==null?null:z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[` `,`(`,t.toLocaleString(),`)`]}),n?z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[` `,`· `,n]}):null]}),h==null?null:z(`span`,{className:`text-muted-foreground text-xs`,children:h})]}),z(`div`,{className:`border-border overflow-auto rounded-md border`,children:z(`table`,{className:`w-full text-sm`,children:[z(`thead`,{className:`bg-muted text-muted-foreground border-b-2 border-border text-xs tracking-wide uppercase`,children:z(`tr`,{children:[u?z(Ot,{children:`#`}):null,i.map(e=>z(Ot,{align:e.align,sortable:e.sortable,active:e.sortable&&o===e.key,dir:s,onClick:e.sortable&&c?()=>c(e.key):void 0,children:e.header},e.key))]})}),z(`tbody`,{children:a.length===0?z(`tr`,{children:z(`td`,{colSpan:m,className:`text-muted-foreground py-8 text-center`,children:l})}):a.map((e,t)=>z(`tr`,{className:`border-border border-t ${p?`hover:bg-muted/60`:``} ${f?f(e,t):``}`.trim().replace(/\s+/g,` `),children:[u?z(`td`,{className:`text-muted-foreground px-3 py-2 tabular-nums`,children:t+1}):null,i.map(n=>z(`td`,{className:`px-3 py-2 ${n.align===`right`?`text-right tabular-nums`:``} ${n.className??``}`.trim(),children:n.render(e,t)},n.key))]},d?d(e,t):t))})]})})]})}function Ot({children:e,sortable:t,active:n,dir:r,onClick:i,align:a=`left`}){return z(`th`,{className:[`px-3 py-2 font-semibold`,a===`right`?`text-right`:`text-left`,t?`cursor-pointer select-none hover:text-foreground`:``,n?`text-foreground`:``].filter(Boolean).join(` `),onClick:i,children:[e,t&&n?r===`asc`?` ↑`:` ↓`:null]})}function Y({href:e,label:t=`View`}){return z(`button`,{type:`button`,className:`text-secondary hover:text-secondary/80 text-xs underline`,onClick:()=>dt(e),children:t})}function X(e,t,n){let r=n===`asc`?1:-1;return[...e].sort((e,n)=>{let i=t(e),a=t(n);return i==null&&a==null?0:i==null?1:a==null?-1:i<a?-1*r:i>a?1*r:0})}function kt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.aggregates,e=>t===`name`?e.name:e.created_at,r),[e.aggregates,t,r]);return z(J,{title:`Aggregates`,count:e.total,scope:e.scope,rightHint:`aka billable metrics`,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/meters/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No aggregates match.`,rowKey:(e,t)=>e.id||t})}function At({payload:e}){let[t,n]=I(`name`),[r,i]=I(`asc`),a=L(()=>X(e.contacts,e=>t===`name`?e.name:e.email,r),[e.contacts,t,r]);return z(J,{title:`Contacts`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`email`,header:`Email`,sortable:!0,className:`text-secondary`,render:e=>e.email||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-secondary font-mono text-xs`,render:e=>W(e.customer_id,10)},{key:`send_invoice`,header:`Send Invoice`,className:`text-xs`,render:e=>e.send_invoice==null?z(B,{children:`—`}):e.send_invoice?`yes`:`no`},{key:`send_contract`,header:`Send Contract`,className:`text-xs`,render:e=>e.send_contract==null?z(B,{children:`—`}):e.send_contract?`yes`:`no`},{key:`view`,header:`View`,render:e=>z(Y,{href:`/contacts/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`asc`))},emptyMessage:`No contacts match.`,rightHint:null,rowKey:(e,t)=>e.id||t})}var jt=`text-muted-foreground text-[11px] tracking-wide uppercase`;function Z({label:e,value:t,tone:n}){return z(`div`,{children:[z(`div`,{className:jt,children:e}),z(`div`,{className:n===`warn`?`text-2xl font-bold tabular-nums text-destructive`:`text-2xl font-bold tabular-nums`,children:t})]})}function Q({title:e,children:t}){return z(`section`,{className:`space-y-1`,children:[z(`div`,{className:jt,children:e}),t]})}function $({label:e,children:t}){return z(`div`,{children:[z(`div`,{className:jt,children:e}),z(`div`,{className:`text-sm`,children:t})]})}function Mt({payload:e}){let t=e.contract,n=e.phases||[],r=new Date;return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:[z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[t.name||z(B,{children:`—`}),t.status?z(q,{status:t.status}):null]}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]}),z(`div`,{className:`flex gap-2`,children:t.contract_link?z(`a`,{href:t.contract_link,target:`_blank`,rel:`noreferrer`,className:`border-border bg-accent text-accent-foreground hover:bg-primary hover:text-primary-foreground rounded border px-3 py-1 text-xs transition-colors`,children:`Open`}):null})]}),z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:[z($,{label:`Customer`,children:t.customer_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.customer_name}),t.customer_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.customer_id}):null]}):t.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.customer_id}):z(B,{children:`—`})}),z($,{label:`Currency`,children:t.currency?z(`span`,{className:`font-mono text-xs`,children:t.currency}):z(B,{children:`—`})}),z($,{label:`Type`,children:t.contract_type||z(B,{children:`—`})}),z($,{label:`Term`,children:t.start_date&&t.end_date?z(`span`,{className:`text-sm`,children:[t.start_date.slice(0,10),` → `,t.end_date.slice(0,10)]}):z(B,{children:`—`})}),z($,{label:`Anchor Date`,children:V(t.anchor_date)}),z($,{label:`Renewal Policy`,children:t.renewal_policy||z(B,{children:`—`})}),z($,{label:`Plan`,children:t.plan_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.plan_id}):z(B,{children:`—`})}),z($,{label:`Created`,children:V(t.created_at)})]}),t.description?z(Q,{title:`Description`,children:z(`div`,{className:`text-sm`,children:t.description})}):null,t.tags&&t.tags.length>0?z(Q,{title:`Tags`,children:z(`div`,{className:`flex flex-wrap gap-2`,children:t.tags.map((e,t)=>z(`span`,{className:`bg-muted text-muted-foreground rounded-full px-2 py-0.5 text-xs`,children:e},t))})}):null,n.length>0?z(Q,{title:`Phases (${n.length})`,children:z(`div`,{className:`space-y-2`,children:n.map((e,t)=>z(Nt,{phase:e,index:t,today:r},e.id||t))})}):null,t.custom_attributes&&Object.keys(t.custom_attributes).length>0?z(Q,{title:`Custom Attributes`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_attributes).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function Nt({phase:e,index:t,today:n}){let r=e.start_date?new Date(e.start_date):null,i=e.end_date?new Date(e.end_date):null,a=r&&i&&r<=n&&n<=i;return z(`div`,{className:`border-border rounded-md border p-3 ${a?`ring-2 ring-ring`:``}`,children:[z(`div`,{className:`flex items-baseline justify-between gap-2`,children:[z(`div`,{className:`text-sm font-medium`,children:[z(`span`,{className:`text-muted-foreground mr-2`,children:[`#`,t+1]}),e.name||z(B,{children:`Untitled phase`}),a?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 ml-2 rounded-full px-2 py-0.5 text-xs ring-1`,children:`current`}):null]}),z(`div`,{className:`text-muted-foreground text-xs whitespace-nowrap`,children:[e.start_date?e.start_date.slice(0,10):`—`,` →`,` `,e.end_date?e.end_date.slice(0,10):`—`]})]}),z(`div`,{className:`mt-1 grid grid-cols-2 gap-2 text-xs sm:grid-cols-3`,children:[z(`div`,{children:[z(`span`,{className:`text-muted-foreground`,children:`Products:`}),` `,z(`span`,{className:`tabular-nums`,children:e.product_count??`—`})]}),e.pricing_summary?z(`div`,{className:`text-muted-foreground col-span-full sm:col-span-2`,children:e.pricing_summary}):null]})]})}function Pt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.contracts,e=>{switch(t){case`name`:return e.name;case`start_date`:return e.start_date;case`end_date`:return e.end_date;case`created_at`:return e.created_at??null}},r),[e.contracts,t,r]);return z(J,{title:`Contracts`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-xs`,render:e=>e.customer_name?e.customer_name:z(`span`,{className:`text-secondary font-mono`,children:W(e.customer_id,10)})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`currency`,header:`Currency`,className:`font-mono text-xs`,render:e=>e.currency||z(B,{children:`—`})},{key:`start_date`,header:`Start`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.start_date)},{key:`end_date`,header:`End`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.end_date)},{key:`days_left`,header:`Days Left`,align:`right`,render:e=>{let t=e.end_date?-1*(_t(e.end_date)??0):null;if(t==null)return z(B,{children:`—`});let n=t<0;return z(`span`,{className:n?`text-destructive font-medium`:!n&&t<=30?`text-primary font-medium`:`text-muted-foreground`,children:n?`${Math.abs(t)}d ago`:`${t}d`})}},{key:`view`,header:`View`,render:e=>z(Y,{href:`/contractsv2/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No contracts match.`,rowKey:(e,t)=>e.id||t})}function Ft({payload:e}){let t=e.credit_note,n=t.currency||`USD`;return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[z(`span`,{className:`font-mono`,children:t.credit_note_number||t.id}),t.status?z(q,{status:t.status}):null]}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]})}),z(`div`,{className:`border-border grid grid-cols-2 gap-3 rounded-md border p-3 sm:grid-cols-4`,children:[z(Z,{label:`Amount`,value:t.amount==null?z(B,{children:`—`}):U(t.amount,n)}),z(Z,{label:`Currency`,value:n}),z(Z,{label:`Credits Returned`,value:t.credits_returned==null?z(B,{children:`—`}):t.credits_returned.toLocaleString()}),z(Z,{label:`Created`,value:V(t.created_at)})]}),z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:[z($,{label:`Customer`,children:t.customer_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.customer_name}),t.customer_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.customer_id}):null]}):t.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.customer_id}):z(B,{children:`—`})}),z($,{label:`Invoice`,children:t.invoice_number?z(`div`,{children:[z(`div`,{className:`font-mono text-sm`,children:t.invoice_number}),t.invoice_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.invoice_id}):null]}):t.invoice_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.invoice_id}):z(B,{children:`—`})}),z($,{label:`Repayment Method`,children:t.repayment_method||z(B,{children:`—`})})]}),t.custom_data&&Object.keys(t.custom_data).length>0?z(Q,{title:`Custom Data`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_data).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function It({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=e.default_currency||`USD`,o=L(()=>X(e.credit_notes,e=>{switch(t){case`amount`:return e.amount;case`created_at`:return e.created_at;case`status`:return e.status}},r),[e.credit_notes,t,r]);return z(J,{title:`Credit Notes`,count:e.total,scope:e.scope,columns:[{key:`number`,header:`Number`,className:`font-mono text-xs`,render:e=>e.credit_note_number||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-xs`,render:e=>e.customer_name?e.customer_name:z(`span`,{className:`text-secondary font-mono`,children:W(e.customer_id,10)})},{key:`invoice`,header:`Invoice`,className:`text-xs`,render:e=>e.invoice_name?e.invoice_name:z(`span`,{className:`text-secondary font-mono`,children:W(e.invoice_id,10)})},{key:`status`,header:`Status`,sortable:!0,render:e=>z(q,{status:e.status})},{key:`amount`,header:`Amount`,sortable:!0,align:`right`,className:`text-destructive`,render:e=>U(e.amount,e.currency||a)},{key:`repayment`,header:`Repayment`,className:`text-xs`,render:e=>e.repayment_method||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)}],rows:o,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},emptyMessage:`No credit notes match.`,rowKey:(e,t)=>e.id||t,hoverRows:!1})}function Lt({payload:e}){let t=e.customer,n=t.address||{},r=[n.line1,n.line2,n.city,n.state,n.zipCode||n.zip_code,n.country].filter(Boolean).join(`, `),i=t.ship_to_address||{},a=[i.line1,i.line2,i.city,i.state,i.zipCode||i.zip_code,i.country].filter(Boolean).join(`, `);return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:t.name||z(B,{children:`—`})}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]})}),z(Rt,{children:[z($,{label:`External ID`,children:t.external_id?z(`span`,{className:`font-mono text-xs`,children:t.external_id}):z(B,{children:`—`})}),z($,{label:`Email`,children:t.email||z(B,{children:`—`})}),z($,{label:`Phone`,children:t.phone||z(B,{children:`—`})}),z($,{label:`Business Entity`,children:t.business_entity_name?z(`div`,{children:[z(`div`,{children:t.business_entity_name}),t.business_entity_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.business_entity_id}):null]}):t.business_entity_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.business_entity_id}):z(B,{children:`—`})}),z($,{label:`Created`,children:V(t.created_at)}),z($,{label:`Updated`,children:V(t.updated_at)})]}),r?z(Q,{title:`Primary Address`,children:z(`div`,{className:`text-sm`,children:r})}):null,a&&a!==r?z(Q,{title:`Ship-to Address`,children:z(`div`,{className:`text-sm`,children:a})}):null,t.communications_enabled!=null||t.auto_charge_enabled!=null?z(Q,{title:`Settings`,children:z(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[z(zt,{label:`Communications`,on:t.communications_enabled??null}),z(zt,{label:`Auto-charge`,on:t.auto_charge_enabled??null})]})}):null,t.default_payment_method?z(Q,{title:`Payment Method`,children:z(`div`,{className:`flex items-center gap-2 text-sm`,children:[z(`span`,{className:`bg-muted rounded px-2 py-0.5 text-xs`,children:(t.default_payment_method.type||`unknown`).replace(/_/g,` `)}),t.default_payment_method.brand?z(`span`,{children:t.default_payment_method.brand}):null,t.default_payment_method.last4?z(`span`,{className:`font-mono`,children:[`•••• `,t.default_payment_method.last4]}):null,t.default_payment_method.connector_name?z(`span`,{className:`text-muted-foreground text-xs`,children:[`via `,t.default_payment_method.connector_name]}):null]})}):null,t.tax_info&&t.tax_info.length>0?z(Q,{title:`Tax Info`,children:z(`div`,{className:`space-y-1`,children:t.tax_info.map((e,t)=>z(`div`,{className:`flex gap-3 text-sm`,children:[e.tax_code?z(`span`,{className:`bg-muted rounded px-2 py-0.5 text-xs`,children:e.tax_code}):null,e.tax_id?z(`span`,{className:`font-mono text-xs`,children:e.tax_id}):null,e.country_code?z(`span`,{className:`text-muted-foreground text-xs`,children:e.country_code}):null]},t))})}):null,t.contacts&&t.contacts.length>0?z(Q,{title:`Contacts (${t.contacts.length})`,children:z(`div`,{className:`space-y-2`,children:t.contacts.map((e,t)=>z(`div`,{className:`border-border flex items-center justify-between rounded border px-3 py-2`,children:[z(`div`,{children:[z(`div`,{className:`text-sm font-medium`,children:e.name||z(B,{children:`—`})}),e.email?z(`div`,{className:`text-muted-foreground text-xs`,children:e.email}):null]}),z(`div`,{className:`flex gap-2`,children:[e.send_invoice?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`invoice`}):null,e.send_contract?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`contract`}):null]})]},t))})}):null,t.custom_data&&Object.keys(t.custom_data).length>0?z(Q,{title:`Custom Data`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_data).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function Rt({children:e}){return z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:e})}function zt({label:e,on:t}){return t===null?null:z(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${t?`bg-secondary/20 text-secondary ring-1 ring-secondary/30`:`bg-muted text-muted-foreground ring-1 ring-border`}`,children:[e,`: `,t?`on`:`off`]})}function Bt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.customers,e=>t===`name`?e.name:e.created_at??null,r),[e.customers,t,r]);return z(J,{title:`Customers`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`external_id`,header:`External ID`,className:`font-mono text-xs`,render:e=>e.external_id||z(B,{children:`—`})},{key:`email`,header:`Email`,className:`text-secondary`,render:e=>e.email||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/customers/${e.id}/view`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No customers match.`,rowKey:(e,t)=>e.id||t})}function Vt({payload:e}){return z(J,{title:`Entitlements`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Entitlement`,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`entitlement_type`,header:`Type`,className:`text-xs`,render:e=>e.entitlement_type||z(B,{children:`—`})},{key:`units`,header:`Units`,className:`font-mono text-xs`,render:e=>e.units||z(B,{children:`—`})},{key:`product_name`,header:`Product`,className:`text-xs`,render:e=>e.product_name||z(B,{children:`—`})},{key:`is_active`,header:`Status`,className:`text-xs`,render:e=>e.is_active==null?z(B,{children:`—`}):e.is_active?`active`:`inactive`},{key:`created_at`,header:`Created`,className:`whitespace-nowrap`,render:e=>V(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/entitlements/${e.id}/edit`})}],rows:e.entitlements,emptyMessage:`No entitlements match.`,rowKey:(e,t)=>e.id||t})}function Ht({payload:e}){return z(J,{title:`Business Entities`,count:e.total,columns:[{key:`name`,header:`Name`,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`email`,header:`Email`,className:`text-secondary text-xs`,render:e=>e.email||z(B,{children:`—`})},{key:`phone`,header:`Phone`,className:`font-mono text-xs`,render:e=>e.phone_number||z(B,{children:`—`})},{key:`country`,header:`Country`,className:`text-xs`,render:e=>e.country||z(B,{children:`—`})},{key:`default`,header:`Default`,className:`text-xs`,render:e=>e.is_default==null?z(B,{children:`—`}):e.is_default?`yes`:`no`},{key:`view`,header:`View`,render:e=>z(Y,{href:`/settings/tax-configuration/entity/${e.id}`})}],rows:e.entities,emptyMessage:`No business entities to show.`,rightHint:null,rowKey:(e,t)=>e.id||t})}function Ut({payload:e}){let t=e.invoice,n=t.currency||`USD`,r=t.due_date&&t.amount_due&&t.amount_due>0?_t(t.due_date):null,i=r!=null&&r>0;return z(`div`,{className:`space-y-4`,children:[z(`header`,{className:`flex items-start justify-between gap-3`,children:[z(`div`,{children:[z(`h2`,{className:`m-0 flex items-center gap-2 text-lg font-semibold`,children:[z(`span`,{className:`font-mono`,children:t.invoice_number||t.id}),t.status?z(q,{status:t.status}):null,i?z(`span`,{className:`bg-destructive/20 text-destructive ring-destructive/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:[r,`d overdue`]}):null]}),z(`div`,{className:`text-secondary mt-0.5 font-mono text-xs`,children:t.id})]}),z(`div`,{className:`flex gap-2`,children:[t.invoice_pdf?z(Wt,{href:t.invoice_pdf,children:`PDF`}):null,t.payment_url?z(Wt,{href:t.payment_url,children:`Payment link`}):null]})]}),z(`div`,{className:`border-border grid grid-cols-2 gap-3 rounded-md border p-3 sm:grid-cols-4`,children:[z(Z,{label:`Total`,value:U(t.invoice_total,n)}),z(Z,{label:`Paid`,value:U(t.paid_amount,n)}),z(Z,{label:`Due`,value:U(t.amount_due,n),tone:i?`warn`:void 0}),z(Z,{label:`Period`,value:t.invoice_period_begin&&t.invoice_period_end?z(`span`,{className:`text-sm`,children:[t.invoice_period_begin.slice(0,10),` →`,` `,t.invoice_period_end.slice(0,10)]}):z(B,{children:`—`})})]}),z(`div`,{className:`border-border grid grid-cols-1 gap-3 rounded-md border p-3 sm:grid-cols-2`,children:[z($,{label:`Customer`,children:t.customer_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.customer_name}),t.customer_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.customer_id}):null]}):t.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.customer_id}):z(B,{children:`—`})}),z($,{label:`Business Entity`,children:t.business_entity_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.business_entity_id}):z(B,{children:`—`})}),z($,{label:`Contract`,children:t.contract_name?z(`div`,{children:[z(`div`,{className:`text-sm`,children:t.contract_name}),t.contract_id?z(`div`,{className:`text-muted-foreground font-mono text-[11px] break-all`,children:t.contract_id}):null]}):t.contract_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:t.contract_id}):z(B,{children:`—`})}),z($,{label:`External ID`,children:t.external_id?z(`span`,{className:`font-mono text-xs`,children:t.external_id}):z(B,{children:`—`})}),z($,{label:`Created`,children:H(t.created_at)}),z($,{label:`Due Date`,children:V(t.due_date)}),z($,{label:`Currency`,children:n})]}),t.notes?z(Q,{title:`Notes`,children:z(`div`,{className:`max-w-prose text-sm`,children:t.notes})}):null,t.approved_at||t.sent_at||t.paid_at?z(Q,{title:`Timeline`,children:z(`div`,{className:`flex flex-wrap gap-4 text-sm`,children:[t.sent_at?z(`div`,{children:[z(`span`,{className:`text-muted-foreground text-xs`,children:`Sent `}),z(`span`,{className:`tabular-nums`,children:H(t.sent_at)})]}):null,t.approved_at?z(`div`,{children:[z(`span`,{className:`text-muted-foreground text-xs`,children:`Approved `}),z(`span`,{className:`tabular-nums`,children:H(t.approved_at)})]}):null,t.paid_at?z(`div`,{children:[z(`span`,{className:`text-muted-foreground text-xs`,children:`Paid `}),z(`span`,{className:`tabular-nums`,children:H(t.paid_at)})]}):null]})}):null,t.custom_data&&Object.keys(t.custom_data).length>0?z(Q,{title:`Custom Data`,children:z(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:Object.entries(t.custom_data).map(([e,t])=>z(`div`,{className:`border-border rounded border px-2 py-1`,children:[z(`div`,{className:`text-muted-foreground`,children:e}),z(`div`,{className:`font-mono`,children:typeof t==`object`?JSON.stringify(t):String(t??``)})]},e))})}):null]})}function Wt({children:e,href:t}){return z(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`border-border bg-accent text-accent-foreground hover:bg-primary hover:text-primary-foreground rounded border px-3 py-1 text-xs transition-colors`,children:e})}function Gt({payload:e}){let t=Ee(null),[n,r]=I(400),[i,a]=I(!1);return Te(()=>{if(!(!t.current||!i))try{let e=t.current.contentDocument;if(e?.documentElement){let t=e.documentElement.scrollHeight;t>0&&r(Math.min(t+16,2e3))}}catch{}},[i,e.html]),e.html?z(`div`,{className:`space-y-2`,children:[e.invoice_id?z(`header`,{className:`flex items-baseline gap-2`,children:[z(`h2`,{className:`m-0 text-lg font-semibold`,children:`Invoice Preview`}),z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:e.invoice_id})]}):null,z(`div`,{className:`border-border overflow-hidden rounded-md border`,children:z(`iframe`,{ref:t,title:`Invoice preview`,srcDoc:e.html,onLoad:()=>a(!0),style:{width:`100%`,height:`${n}px`,border:`none`,background:`#fff`},sandbox:`allow-same-origin`})})]}):z(`div`,{className:`text-muted-foreground border-border rounded-md border py-8 text-center`,children:`No preview generated for this invoice yet.`})}function Kt({payload:e}){let t=e.currency||`USD`,n=e.lines||[];return z(J,{title:z(S,{children:[`Line Items`,` `,z(`span`,{className:`text-muted-foreground font-normal`,children:[`(`,n.length,`)`]}),e.invoice_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:[` `,`· `,e.invoice_id]}):null]}),rightHint:e.total==null?null:z(`span`,{className:`text-sm`,children:[`Total:`,` `,z(`span`,{className:`font-medium tabular-nums`,children:U(e.total,t)})]}),columns:[{key:`type`,header:`Type`,className:`text-muted-foreground text-xs`,render:e=>z(`div`,{className:`flex items-center gap-1`,children:[e.line_item_type?e.line_item_type.replace(/_/g,` `):z(B,{children:`—`}),e.is_adjustment?z(`span`,{className:`bg-warning/15 text-warning ring-warning/30 rounded-full px-1.5 py-0.5 text-[10px] ring-1`,children:e.adjustment_type||`adj`}):null]})},{key:`item`,header:`Item`,render:e=>z(S,{children:[z(`div`,{className:`font-medium`,children:e.name||z(B,{children:`—`})}),e.description?z(`div`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{key:`pricing_model`,header:`Pricing Model`,className:`text-muted-foreground text-xs`,render:e=>e.pricing_model||z(B,{children:`—`})},{key:`qty`,header:`Qty`,align:`right`,render:e=>e.quantity?.display||(e.quantity?.value??z(B,{children:`—`}))},{key:`price`,header:`Price`,align:`right`,render:e=>e.price?vt(e.price):z(B,{children:`—`})},{key:`subtotal`,header:`Subtotal`,align:`right`,render:e=>z(`span`,{className:e.subtotal?.value!=null&&e.subtotal.value<0?`text-destructive`:``,children:vt(e.subtotal)})},{key:`period`,header:`Service Period`,className:`text-xs whitespace-nowrap`,render:e=>e.service_start_date&&e.service_end_date?z(S,{children:[V(e.service_start_date),` → `,V(e.service_end_date)]}):z(B,{children:`—`})},{key:`billed`,header:`Billed`,className:`text-xs`,render:e=>e.is_billed===!0?`✓`:e.is_billed===!1?`—`:z(B,{children:`?`})}],rows:n,emptyMessage:`No line items on this invoice.`,hoverRows:!1})}function qt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=e.default_currency||`USD`,o=L(()=>X(e.invoices,e=>{switch(t){case`invoice_number`:return e.invoice_number;case`invoice_total`:return e.invoice_total;case`amount_due`:return e.amount_due;case`due_date`:return e.due_date;case`created_at`:return e.created_at}},r),[e.invoices,t,r]),s=e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},c=e=>{if(!e.due_date||!e.amount_due||e.amount_due<=0)return null;let t=_t(e.due_date);return t!=null&&t>0?t:null};return z(J,{title:`Invoices`,count:e.total,scope:e.scope,columns:[{key:`invoice_number`,header:`Invoice`,sortable:!0,className:`font-mono text-xs`,render:e=>e.invoice_number||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-xs`,render:e=>e.customer_name?e.customer_name:z(`span`,{className:`text-secondary font-mono`,children:W(e.customer_id,10)})},{key:`period`,header:`Period`,className:`text-xs whitespace-nowrap`,render:e=>e.invoice_period_begin&&e.invoice_period_end?`${e.invoice_period_begin.slice(0,10)} → ${e.invoice_period_end.slice(0,10)}`:z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`invoice_total`,header:`Total`,sortable:!0,align:`right`,render:e=>U(e.invoice_total,a)},{key:`amount_due`,header:`Due`,sortable:!0,align:`right`,render:e=>z(`span`,{className:c(e)==null?``:`text-destructive font-medium`,children:U(e.amount_due,a)})},{key:`due_date`,header:`Due Date`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.due_date)},{key:`overdue`,header:`Overdue`,align:`right`,render:e=>{let t=c(e);return t==null?z(`span`,{className:`text-muted-foreground`,children:z(B,{children:`—`})}):z(`span`,{className:`text-destructive font-medium`,children:[t,`d`]})}},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/invoices/${e.id}/view`})}],rows:o,sortKey:t,sortDir:r,onSort:s,emptyMessage:`No invoices match.`,rowKey:(e,t)=>e.id||t})}function Jt({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.jobs,e=>{switch(t){case`name`:return e.name;case`created_at`:return e.created_at;case`status`:return e.status}},r),[e.jobs,t,r]),o=e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},s=e.status_counts||{},c=z(`div`,{className:`flex flex-wrap gap-1.5 text-xs`,children:Object.entries(s).map(([e,t])=>z(`span`,{className:`bg-muted rounded-full px-2 py-0.5`,children:[e,`: `,z(`span`,{className:`font-medium tabular-nums`,children:t})]},e))});return z(J,{title:`Jobs`,count:e.total,rightHint:c,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`type`,header:`Type`,className:`text-xs`,render:e=>e.job_type||z(B,{children:`—`})},{key:`resource`,header:`Resource`,className:`text-xs`,render:e=>e.resource||z(B,{children:`—`})},{key:`status`,header:`Status`,sortable:!0,render:e=>z(q,{status:e.status})},{key:`description`,header:`Description`,className:`text-muted-foreground max-w-xs truncate text-xs`,render:e=>e.description||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`text-xs whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/jobs/${e.id}/view`})}],rows:a,sortKey:t,sortDir:r,onSort:o,emptyMessage:`No jobs match.`,rowKey:(e,t)=>e.id||t})}function Yt({payload:e}){let t=e.default_currency||`USD`,n=e.entries,r=L(()=>{let e=0,t=0;for(let r of n)Number.isFinite(r.total_debit)&&(e+=r.total_debit),Number.isFinite(r.total_credit)&&(t+=r.total_credit);return{d:e,c:t}},[n]),i=z(S,{children:[`Σ debit `,U(r.d,t),` · Σ credit `,U(r.c,t)]});return z(J,{title:`Journal Entries`,count:e.total,scope:e.scope,rightHint:i,columns:[{key:`posted_at`,header:`Posted`,className:`whitespace-nowrap`,render:e=>H(e.posted_at)},{key:`event`,header:`Event`,className:`text-xs`,render:e=>e.event||z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status_type})},{key:`lines`,header:`Lines`,align:`right`,render:e=>e.line_count??z(B,{children:`—`})},{key:`total_debit`,header:`Σ Debit`,align:`right`,render:e=>e.total_debit==null?z(B,{children:`—`}):U(e.total_debit,e.currency||t)},{key:`total_credit`,header:`Σ Credit`,align:`right`,render:e=>e.total_credit==null?z(B,{children:`—`}):U(e.total_credit,e.currency||t)},{key:`description`,header:`Description`,className:`text-muted-foreground max-w-xs truncate text-xs`,render:e=>e.description||z(B,{children:`—`})}],rows:n,emptyMessage:`No entries match.`,rowKey:(e,t)=>e.id||t,hoverRows:!1})}function Xt({payload:e}){let t=e.payment_methods||[];return z(`div`,{className:`space-y-3`,children:[z(`header`,{className:`flex items-baseline justify-between gap-3`,children:z(`h2`,{className:`m-0 text-lg font-semibold`,children:[`Payment Methods`,` `,z(`span`,{className:`text-muted-foreground text-sm font-normal`,children:[`(`,t.length,`)`]}),e.customer_id?z(`span`,{className:`text-secondary font-mono text-xs break-all`,children:[` `,`· `,e.customer_id]}):null]})}),t.length===0?z(`div`,{className:`text-muted-foreground border-border rounded-md border py-8 text-center`,children:`No payment methods saved.`}):z(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:t.map((e,t)=>z(Zt,{method:e},e.id||t))})]})}function Zt({method:e}){let t=(e.type||``).toLowerCase().includes(`card`);return z(`article`,{className:`space-y-1 rounded-md border p-3 ${e.is_default?`border-ring ring-ring ring-1`:`border-border`}`,children:[z(`header`,{className:`flex items-baseline justify-between gap-2`,children:[z(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[z(`span`,{className:`bg-muted rounded px-2 py-0.5 text-xs`,children:(e.type||`unknown`).replace(/_/g,` `)}),e.brand?z(`span`,{className:`text-muted-foreground`,children:e.brand}):null,e.connector_name?z(`span`,{className:`text-muted-foreground text-xs`,children:[`via `,e.connector_name]}):null]}),e.is_default?z(`span`,{className:`bg-secondary/20 text-secondary ring-secondary/30 rounded-full px-2 py-0.5 text-xs ring-1`,children:`default`}):null]}),z(`div`,{className:`font-mono text-sm`,children:e.last4?`•••• ${e.last4}`:z(B,{children:`—`})}),z(`div`,{className:`text-muted-foreground flex gap-3 text-xs`,children:[e.status?z(`span`,{className:`rounded-full px-2 py-0.5 text-xs ring-1 ${e.status===`valid`?`bg-secondary/20 text-secondary ring-secondary/30`:`bg-destructive/20 text-destructive ring-destructive/30`}`,children:e.status}):null,t&&e.exp_month&&e.exp_year?z(`span`,{children:[`exp `,String(e.exp_month).padStart(2,`0`),`/`,String(e.exp_year).slice(-2)]}):null,e.created_at?z(`span`,{children:[`added `,V(e.created_at)]}):null]})]})}var Qt={payment:`bg-secondary/20 text-secondary ring-1 ring-secondary/30`,refund:`bg-accent text-accent-foreground ring-1 ring-border`,payment_reversal:`bg-destructive/20 text-destructive ring-1 ring-destructive/30`,authorization:`bg-primary/20 text-primary ring-1 ring-primary/30`,tax_withheld:`bg-muted text-muted-foreground ring-1 ring-border`},$t=`bg-muted text-muted-foreground ring-1 ring-border`;function en({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=e.default_currency||`USD`,o=L(()=>X(e.payments,e=>{switch(t){case`amount`:return e.amount;case`payment_date`:return e.payment_date;case`created_at`:return e.created_at;case`type`:return e.type}},r),[e.payments,t,r]);return z(J,{title:`Payments`,count:e.total,scope:e.scope,columns:[{key:`external_id`,header:`External ID`,className:`font-mono text-xs`,render:e=>e.external_id||z(B,{children:`—`})},{key:`customer`,header:`Customer`,className:`text-xs`,render:e=>e.customer_name?e.customer_name:z(`span`,{className:`text-secondary font-mono`,children:W(e.customer_id,10)})},{key:`invoice`,header:`Invoice`,className:`text-xs`,render:e=>e.invoice_name?e.invoice_name:z(`span`,{className:`text-secondary font-mono`,children:W(e.invoice_id,10)})},{key:`type`,header:`Type`,sortable:!0,render:e=>e.type?z(`span`,{className:`inline-block rounded-full px-2 py-0.5 text-xs ${Qt[e.type]||$t}`,children:e.type}):z(B,{children:`—`})},{key:`method`,header:`Method`,className:`text-xs`,render:e=>e.payment_method||z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`amount`,header:`Amount`,sortable:!0,align:`right`,render:e=>{let t=e.amount!=null&&e.amount<0,n=e.type===`refund`||e.type===`payment_reversal`;return z(`span`,{className:t||n?`text-destructive`:``,children:U(e.amount,e.currency||a)})}},{key:`payment_date`,header:`Date`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.payment_date)},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)}],rows:o,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))},emptyMessage:`No payments match.`,rowKey:(e,t)=>e.id||t,hoverRows:!1})}function tn({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.plans,e=>t===`name`?e.name:e.created_at,r),[e.plans,t,r]);return z(J,{title:`Plans`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`description`,header:`Description`,className:`text-muted-foreground text-xs`,render:e=>e.description||z(B,{children:`—`})},{key:`status`,header:`Status`,render:e=>z(q,{status:e.status})},{key:`plan_version`,header:`Version`,align:`right`,render:e=>e.plan_version??z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/plansv2/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No plans match.`,rowKey:(e,t)=>e.id||t})}function nn({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.products,e=>t===`name`?e.name:e.created_at,r),[e.products,t,r]);return z(J,{title:`Products`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`sku`,header:`SKU`,className:`font-mono text-xs`,render:e=>e.sku||z(B,{children:`—`})},{key:`type`,header:`Type`,className:`text-xs`,render:e=>e.product_type||z(B,{children:`—`})},{key:`active`,header:`Active`,className:`text-xs`,render:e=>e.is_active==null?z(B,{children:`—`}):e.is_active?`yes`:`no`},{key:`description`,header:`Description`,className:`text-muted-foreground text-xs`,render:e=>e.description||z(B,{children:`—`})},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>H(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/products/${e.id}/edit`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No products match.`,rowKey:(e,t)=>e.id||t})}function rn({payload:e}){let[t,n]=I(`created_at`),[r,i]=I(`desc`),a=L(()=>X(e.raw_metrics,e=>t===`name`?e.name:e.created_at,r),[e.raw_metrics,t,r]);return z(J,{title:`Raw Metrics`,count:e.total,scope:e.scope,columns:[{key:`name`,header:`Name`,sortable:!0,className:`font-medium`,render:e=>e.name||z(B,{children:`—`})},{key:`api_slug`,header:`API Slug`,className:`font-mono text-xs`,render:e=>e.api_slug||z(B,{children:`—`})},{key:`upload`,header:`Upload Enabled`,className:`text-xs`,render:e=>e.usage_upload_enabled==null?z(B,{children:`—`}):e.usage_upload_enabled?`yes`:`no`},{key:`created_at`,header:`Created`,sortable:!0,className:`whitespace-nowrap`,render:e=>V(e.created_at)},{key:`view`,header:`View`,render:e=>z(Y,{href:`/meters/raw-metrics/${e.id}/view`})}],rows:a,sortKey:t,sortDir:r,onSort:e=>{e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(e===`name`?`asc`:`desc`))},emptyMessage:`No raw metrics match.`,rowKey:(e,t)=>e.id||t})}var an={name:`Zenskar`,version:`1.0.0`},on=`2026-01-26`,sn={listCustomers:{fallback:{customers:[],total:0},marker:`customer-table:mounted`,render:e=>z(Bt,{payload:e})},listInvoices:{fallback:{invoices:[],total:0},marker:`invoice-table:mounted`,render:e=>z(qt,{payload:e})},getInvoiceLineItems:{fallback:{lines:[]},marker:`invoice-line-items:mounted`,render:e=>z(Kt,{payload:e})},listAllPayments:{fallback:{payments:[],total:0},marker:`payment-table:mounted`,render:e=>z(en,{payload:e})},listCreditNotes:{fallback:{credit_notes:[],total:0},marker:`credit-note-table:mounted`,render:e=>z(It,{payload:e})},listContracts:{fallback:{contracts:[],total:0},marker:`contract-table:mounted`,render:e=>z(Pt,{payload:e})},getCustomerById:{fallback:{customer:{id:``}},marker:`customer-detail:mounted`,render:e=>z(Lt,{payload:e})},getInvoiceById:{fallback:{invoice:{id:``}},marker:`invoice-detail:mounted`,render:e=>z(Ut,{payload:e})},getContractById:{fallback:{contract:{id:``},phases:[]},marker:`contract-detail:mounted`,render:e=>z(Mt,{payload:e})},getCreditNoteById:{fallback:{credit_note:{id:``}},marker:`credit-note-detail:mounted`,render:e=>z(Ft,{payload:e})},listProducts:{fallback:{products:[],total:0},marker:`product-table:mounted`,render:e=>z(nn,{payload:e})},listPlans:{fallback:{plans:[],total:0},marker:`plan-table:mounted`,render:e=>z(tn,{payload:e})},listJournalEntries:{fallback:{entries:[],total:0},marker:`journal-table:mounted`,render:e=>z(Yt,{payload:e})},listJobs:{fallback:{jobs:[],total:0},marker:`job-table:mounted`,render:e=>z(Jt,{payload:e})},listContacts:{fallback:{contacts:[],total:0},marker:`contact-table:mounted`,render:e=>z(At,{payload:e})},listRawMetrics:{fallback:{raw_metrics:[],total:0},marker:`raw-metric-table:mounted`,render:e=>z(rn,{payload:e})},listAggregates:{fallback:{aggregates:[],total:0},marker:`aggregate-table:mounted`,render:e=>z(kt,{payload:e})},listCustomerAddresses:{fallback:{addresses:[]},marker:`address-list:mounted`,render:e=>z(Et,{payload:e})},listPaymentMethods:{fallback:{payment_methods:[]},marker:`payment-method-list:mounted`,render:e=>z(Xt,{payload:e})},listBusinessEntities:{fallback:{entities:[]},marker:`entity-table:mounted`,render:e=>z(Ht,{payload:e})},listEntitlements:{fallback:{entitlements:[],total:0},marker:`entitlement-table:mounted`,render:e=>z(Vt,{payload:e})},getInvoicePreviewHtml:{fallback:{html:``},marker:`invoice-preview:mounted`,render:e=>z(Gt,{payload:e})}};function cn(){return typeof window>`u`?null:window.openai??null}function ln(){let e=cn(),[t,n]=I(e?.toolInput?.toolName??null),[r,i]=I(e?.toolOutput??null),a=Ee(null);if(Te(()=>{let e=ft(`ui/notifications/tool-result`,e=>{let t=e;t&&Object.prototype.hasOwnProperty.call(t,`structuredContent`)&&i(t.structuredContent??null)}),t=ft(`ui/notifications/host-context-changed`,e=>{let t=e?.toolInfo?.tool?.name;typeof t==`string`&&n(t)});return ct(`ui/initialize`,{appCapabilities:{},appInfo:an,protocolVersion:on}).then(e=>{let t=e?.hostContext?.toolInfo?.tool?.name;typeof t==`string`&&n(t),lt(`ui/notifications/initialized`)}).catch(()=>{}),()=>{e(),t()}},[]),Te(()=>{let e=e=>{let t=e?.detail?.globals;t&&(t.toolInput?.toolName&&n(t.toolInput.toolName),Object.prototype.hasOwnProperty.call(t,`toolOutput`)&&i(t.toolOutput??null))};return window.addEventListener(`openai:set_globals`,e,{passive:!0}),()=>{window.removeEventListener(`openai:set_globals`,e)}},[]),Te(()=>{if(r===null||!t)return;let e=sn[t];if(e?.marker&<(`ui/message`,{hidden:!0,marker:e.marker}),!a.current)return;let n=()=>{let e=a.current.getBoundingClientRect();lt(`ui/notifications/size-changed`,{width:Math.round(e.width),height:Math.round(e.height)})};n();let i=new ResizeObserver(n);return i.observe(a.current),()=>i.disconnect()},[r,t]),!t||!sn[t])return z(`div`,{"data-app-loading":!0,style:{visibility:`hidden`,minHeight:1}});let o=sn[t];if(r===null&&!e?.toolOutput)return z(`div`,{"data-app-loading":!0,style:{visibility:`hidden`,minHeight:1}});let s=r??o.fallback;return z(`div`,{ref:a,className:`text-foreground bg-background p-4 font-sans text-[14px]`,children:o.render(s)})}var un=document.getElementById(`root`);un&&at(un).render(z(S,{children:z(ln,{})}));</script>
|
|
8
8
|
<style rel="stylesheet" crossorigin>/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
|
|
9
9
|
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after{--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}::backdrop{--tw-space-y-reverse:0;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--font-sans:var(--font-sans);--font-serif:var(--font-serif);--font-mono:var(--font-mono);--spacing:.25rem;--container-xs:20rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-normal:var(--tracking-normal);--shadow-2xs:var(--shadow-2xs);--shadow-xs:var(--shadow-xs);--shadow-sm:var(--shadow-sm);--shadow-md:var(--shadow-md);--shadow-lg:var(--shadow-lg);--shadow-xl:var(--shadow-xl);--shadow-2xl:var(--shadow-2xl);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--shadow:var(--shadow)}}@layer base{*,:after,:before{box-sizing:border-box;border:0 solid;margin:0;padding:0}::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:var(--border);outline-color:var(--ring)}@supports (color:color-mix(in lab, red, red)){*{outline-color:color-mix(in oklab, var(--ring) 50%, transparent)}}body{background-color:var(--background);color:var(--foreground);letter-spacing:var(--tracking-normal)}h1,h2,h3{letter-spacing:-.005em;line-height:1.2}}@layer components;@layer utilities{.static{position:static}.sticky{position:sticky}.top-0{top:calc(var(--spacing) * 0)}.z-10{z-index:10}.col-span-full{grid-column:1/-1}.m-0{margin:calc(var(--spacing) * 0)}.mx-auto{margin-inline:auto}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mr-2{margin-right:calc(var(--spacing) * 2)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.min-h-screen{min-height:100vh}.w-12{width:calc(var(--spacing) * 12)}.w-full{width:100%}.max-w-\[1100px\]{max-width:1100px}.max-w-prose{max-width:65ch}.max-w-xs{max-width:var(--container-xs)}.cursor-pointer{cursor:pointer}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-md{border-radius:calc(var(--radius) - 2px)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-border{border-color:var(--border)}.border-ring{border-color:var(--ring)}.bg-accent{background-color:var(--accent)}.bg-background{background-color:var(--background)}.bg-card{background-color:var(--card)}.bg-destructive\/20{background-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.bg-destructive\/20{background-color:color-mix(in oklab, var(--destructive) 20%, transparent)}}.bg-muted{background-color:var(--muted)}.bg-primary\/20{background-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.bg-primary\/20{background-color:color-mix(in oklab, var(--primary) 20%, transparent)}}.bg-secondary\/12{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.bg-secondary\/12{background-color:color-mix(in oklab, var(--secondary) 12%, transparent)}}.bg-secondary\/20{background-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.bg-secondary\/20{background-color:color-mix(in oklab, var(--secondary) 20%, transparent)}}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-8{padding-block:calc(var(--spacing) * 8)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[14px\]{font-size:14px}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:calc(var(--tracking-normal) + .025em);letter-spacing:calc(var(--tracking-normal) + .025em)}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.text-accent-foreground{color:var(--accent-foreground)}.text-card-foreground{color:var(--card-foreground)}.text-destructive{color:var(--destructive)}.text-foreground{color:var(--foreground)}.text-muted-foreground{color:var(--muted-foreground)}.text-primary{color:var(--primary)}.text-secondary{color:var(--secondary)}.uppercase{text-transform:uppercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline{text-decoration-line:underline}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-border{--tw-ring-color:var(--border)}.ring-destructive\/30{--tw-ring-color:var(--destructive)}@supports (color:color-mix(in lab, red, red)){.ring-destructive\/30{--tw-ring-color:color-mix(in oklab, var(--destructive) 30%, transparent)}}.ring-primary\/30{--tw-ring-color:var(--primary)}@supports (color:color-mix(in lab, red, red)){.ring-primary\/30{--tw-ring-color:color-mix(in oklab, var(--primary) 30%, transparent)}}.ring-ring{--tw-ring-color:var(--ring)}.ring-secondary\/20{--tw-ring-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.ring-secondary\/20{--tw-ring-color:color-mix(in oklab, var(--secondary) 20%, transparent)}}.ring-secondary\/30{--tw-ring-color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.ring-secondary\/30{--tw-ring-color:color-mix(in oklab, var(--secondary) 30%, transparent)}}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.select-none{-webkit-user-select:none;user-select:none}.\[mock-host\:postMessage\]{mock-host:postMessage}@media (hover:hover){.hover\:bg-muted\/60:hover{background-color:var(--muted)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-muted\/60:hover{background-color:color-mix(in oklab, var(--muted) 60%, transparent)}}.hover\:bg-primary:hover{background-color:var(--primary)}.hover\:text-foreground:hover{color:var(--foreground)}.hover\:text-primary-foreground:hover{color:var(--primary-foreground)}.hover\:text-secondary\/80:hover{color:var(--secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:text-secondary\/80:hover{color:color-mix(in oklab, var(--secondary) 80%, transparent)}}}@media (min-width:40rem){.sm\:col-span-2{grid-column:span 2/span 2}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}}:root{--background:#fff;--foreground:#111827;--card:#fff;--card-foreground:#111827;--popover:#fff;--popover-foreground:#111827;--primary:#d87943;--primary-foreground:#fff;--secondary:#527575;--secondary-foreground:#fff;--muted:#f3f4f6;--muted-foreground:#6b7280;--accent:#eee;--accent-foreground:#111827;--destructive:#ef4444;--destructive-foreground:#fafafa;--border:#e5e7eb;--input:#e5e7eb;--ring:#d87943;--chart-1:#5f8787;--chart-2:#e78a53;--chart-3:#fbcb97;--chart-4:#888;--chart-5:#999;--sidebar:#f3f4f6;--sidebar-foreground:#111827;--sidebar-primary:#d87943;--sidebar-primary-foreground:#fff;--sidebar-accent:#fff;--sidebar-accent-foreground:#111827;--sidebar-border:#e5e7eb;--sidebar-ring:#d87943;--font-sans:Figtree, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--font-serif:serif;--font-mono:JetBrains Mono, monospace;--radius:.75rem;--shadow-x:0px;--shadow-y:1px;--shadow-blur:4px;--shadow-spread:0px;--shadow-opacity:.05;--shadow-color:#000;--shadow-2xs:0px 1px 4px 0px #00000008;--shadow-xs:0px 1px 4px 0px #00000008;--shadow-sm:0px 1px 4px 0px #0000000d, 0px 1px 2px -1px #0000000d;--shadow:0px 1px 4px 0px #0000000d, 0px 1px 2px -1px #0000000d;--shadow-md:0px 1px 4px 0px #0000000d, 0px 2px 4px -1px #0000000d;--shadow-lg:0px 1px 4px 0px #0000000d, 0px 4px 6px -1px #0000000d;--shadow-xl:0px 1px 4px 0px #0000000d, 0px 8px 10px -1px #0000000d;--shadow-2xl:0px 1px 4px 0px #00000021;--tracking-normal:0rem;--spacing:.25rem}.dark{--background:#121113;--foreground:#c1c1c1;--card:#121212;--card-foreground:#c1c1c1;--popover:#121113;--popover-foreground:#c1c1c1;--primary:#e78a53;--primary-foreground:#121113;--secondary:#5f8787;--secondary-foreground:#121113;--muted:#222;--muted-foreground:#888;--accent:#333;--accent-foreground:#c1c1c1;--destructive:#5f8787;--destructive-foreground:#121113;--border:#222;--input:#222;--ring:#e78a53;--chart-1:#5f8787;--chart-2:#e78a53;--chart-3:#fbcb97;--chart-4:#888;--chart-5:#999;--sidebar:#121212;--sidebar-foreground:#c1c1c1;--sidebar-primary:#e78a53;--sidebar-primary-foreground:#121113;--sidebar-accent:#333;--sidebar-accent-foreground:#c1c1c1;--sidebar-border:#222;--sidebar-ring:#e78a53;--font-sans:Figtree, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--font-serif:serif;--font-mono:JetBrains Mono, monospace;--radius:.75rem;--shadow-x:0px;--shadow-y:1px;--shadow-blur:4px;--shadow-spread:0px;--shadow-opacity:.05;--shadow-color:#000;--shadow-2xs:0px 1px 4px 0px #00000008;--shadow-xs:0px 1px 4px 0px #00000008;--shadow-sm:0px 1px 4px 0px #0000000d, 0px 1px 2px -1px #0000000d;--shadow:0px 1px 4px 0px #0000000d, 0px 1px 2px -1px #0000000d;--shadow-md:0px 1px 4px 0px #0000000d, 0px 2px 4px -1px #0000000d;--shadow-lg:0px 1px 4px 0px #0000000d, 0px 4px 6px -1px #0000000d;--shadow-xl:0px 1px 4px 0px #0000000d, 0px 8px 10px -1px #0000000d;--shadow-2xl:0px 1px 4px 0px #00000021}:root{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light dark}@media (prefers-color-scheme:dark){:root{--lightningcss-light: ;--lightningcss-dark:initial}:root:not(.light){--background:#121113;--foreground:#c1c1c1;--card:#121212;--card-foreground:#c1c1c1;--popover:#121113;--popover-foreground:#c1c1c1;--primary:#e78a53;--primary-foreground:#121113;--secondary:#5f8787;--secondary-foreground:#121113;--muted:#222;--muted-foreground:#888;--accent:#333;--accent-foreground:#c1c1c1;--destructive:#5f8787;--destructive-foreground:#121113;--border:#222;--input:#222;--ring:#e78a53;--chart-1:#5f8787;--chart-2:#e78a53;--chart-3:#fbcb97;--chart-4:#888;--chart-5:#999;--sidebar:#121212;--sidebar-foreground:#c1c1c1;--sidebar-primary:#e78a53;--sidebar-primary-foreground:#121113;--sidebar-accent:#333;--sidebar-accent-foreground:#c1c1c1;--sidebar-border:#222;--sidebar-ring:#e78a53}}html,body{font-family:var(--font-sans);margin:0;font-size:14px;line-height:1.5}table{border-collapse:collapse}.tabular-nums{font-variant-numeric:tabular-nums}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
|
|
10
10
|
/*$vite$:1*/</style>
|
package/package.json
CHANGED