@happyvertical/smrt-planner 0.57.5 → 0.57.7
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/agents/assistant.md +29 -2
- package/agents/shell.md +13 -0
- package/app/404.html +27 -30
- package/app/_app/immutable/assets/0.BaRFeYGU.css +1 -0
- package/app/_app/immutable/assets/AppShell.BkKNrxND.css +1 -0
- package/app/_app/immutable/assets/{ModelPage.FEM0ZnPM.css → ModelPage.SIoeO-AU.css} +1 -1
- package/app/_app/immutable/assets/app.BHwMQ9Zv.css +1 -0
- package/app/_app/immutable/assets/{forms.DXOeP4wZ.css → forms.BRdbPdvs.css} +1 -1
- package/app/_app/immutable/assets/icons.BDx21rPt.css +1 -0
- package/app/_app/immutable/assets/labels.Dxa6EyRI.css +1 -0
- package/app/_app/immutable/assets/planner.DOQVfcOi.css +1 -0
- package/app/_app/immutable/assets/state.C0UZEhxS.css +1 -0
- package/app/_app/immutable/chunks/{C1VofLtR.js → B2uXaQfZ.js} +1 -1
- package/app/_app/immutable/chunks/{DuZeZzOA.js → BQLQsso4.js} +1 -1
- package/app/_app/immutable/chunks/BdOPgmQ_.js +11 -0
- package/app/_app/immutable/chunks/BeL8dJx9.js +4 -0
- package/app/_app/immutable/chunks/{Bal1oPZu.js → Bhd-3niN.js} +1 -1
- package/app/_app/immutable/chunks/{CTlMHIE6.js → BqEBz5Vq.js} +1 -1
- package/app/_app/immutable/chunks/{GdHEbDDH.js → BxyJ_Q7v.js} +1 -1
- package/app/_app/immutable/chunks/{C3sRGrYK.js → C2OYATC6.js} +1 -1
- package/app/_app/immutable/chunks/C6AANt9H.js +26 -0
- package/app/_app/immutable/chunks/{BybfWt-B.js → C8FX0hli.js} +6 -6
- package/app/_app/immutable/chunks/{BDbFl7UA.js → CYhwv6d2.js} +1 -1
- package/app/_app/immutable/chunks/CdKHckEF.js +1 -0
- package/app/_app/immutable/chunks/CsaWd8kG.js +2 -0
- package/app/_app/immutable/chunks/Cwz7QFS4.js +2 -0
- package/app/_app/immutable/chunks/{BG9Gz_25.js → D3lXu_rt.js} +25 -25
- package/app/_app/immutable/chunks/{YGONf0jr.js → D8MqcCKq.js} +1 -1
- package/app/_app/immutable/chunks/DF-0MxNw.js +1 -0
- package/app/_app/immutable/chunks/DGaFQflg.js +1 -0
- package/app/_app/immutable/chunks/DIE02RSm.js +1 -0
- package/app/_app/immutable/chunks/DIgo5ngo.js +1 -0
- package/app/_app/immutable/chunks/{5ukUzDcw.js → Db12RzZi.js} +1 -1
- package/app/_app/immutable/chunks/{Cga8zF3r.js → DfN2k_EX.js} +1 -1
- package/app/_app/immutable/chunks/DmHVTNcC.js +4 -0
- package/app/_app/immutable/chunks/{gCpxN2IC.js → DmdvNG82.js} +2 -2
- package/app/_app/immutable/chunks/{DjJovMrk.js → DwIRC3h5.js} +1 -1
- package/app/_app/immutable/chunks/{nphy1MQF.js → FeyhlLIZ.js} +1 -1
- package/app/_app/immutable/chunks/ICDFUCZL.js +2 -0
- package/app/_app/immutable/chunks/IDZmjRDr.js +1 -0
- package/app/_app/immutable/chunks/JqlEoPqZ.js +1 -0
- package/app/_app/immutable/chunks/{BiEOJeYb.js → TcjpRcdI.js} +1 -1
- package/app/_app/immutable/chunks/Vt9hDpHd.js +1 -0
- package/app/_app/immutable/chunks/ezs6CGyc.js +1 -0
- package/app/_app/immutable/chunks/lUJaueNM.js +16 -0
- package/app/_app/immutable/entry/app.C5bxPKCP.js +2 -0
- package/app/_app/immutable/entry/start.CZvO61qD.js +1 -0
- package/app/_app/immutable/nodes/0.DFJFBCCB.js +7 -0
- package/app/_app/immutable/nodes/{1.DKP901Gn.js → 1.D_79m87b.js} +1 -1
- package/app/_app/immutable/nodes/{10.DNN0cVai.js → 10.20u2-jxn.js} +1 -1
- package/app/_app/immutable/nodes/{11.DgbmegX3.js → 11.CvMq32jC.js} +1 -1
- package/app/_app/immutable/nodes/{12.D5MtnJoE.js → 12.Cd0cy1AC.js} +1 -1
- package/app/_app/immutable/nodes/{13._rY66Xa_.js → 13.DYYS3YVQ.js} +1 -1
- package/app/_app/immutable/nodes/14.BEf5BJDn.js +1 -0
- package/app/_app/immutable/nodes/2.C_kLkHNl.js +24 -0
- package/app/_app/immutable/nodes/{3.V5uGCpGb.js → 3.CZw3hv8O.js} +1 -1
- package/app/_app/immutable/nodes/{4.CCwzLrgu.js → 4.WMU9NDex.js} +1 -1
- package/app/_app/immutable/nodes/{5.CgHzwpns.js → 5.CuqxSfl4.js} +1 -1
- package/app/_app/immutable/nodes/{6.CvQHLh_u.js → 6.BXLQB7tR.js} +1 -1
- package/app/_app/immutable/nodes/{7.7EIrly34.js → 7.BZvxNeL2.js} +1 -1
- package/app/_app/immutable/nodes/{8.DyyRBuTw.js → 8.Bj2O4pyx.js} +1 -1
- package/app/_app/immutable/nodes/{9.DcURs0gN.js → 9.yeFzeUHj.js} +1 -1
- package/app/_app/version.json +1 -1
- package/app/advanced-styles/index.html +34 -35
- package/app/ai/index.html +39 -40
- package/app/blueprint/index.html +29 -32
- package/app/cookbook/index.html +29 -32
- package/app/index.html +39 -42
- package/app/m/ads/AdDeliveryTier/index.html +36 -37
- package/app/m/ads/AdEvent/index.html +36 -37
- package/app/m/ads/AdFormat/index.html +36 -37
- package/app/m/ads/AdGroup/index.html +36 -37
- package/app/m/ads/AdVariation/index.html +36 -37
- package/app/m/analytics/AnalyticsDataStream/index.html +36 -37
- package/app/m/analytics/AnalyticsEvent/index.html +36 -37
- package/app/m/analytics/AnalyticsProperty/index.html +36 -37
- package/app/m/analytics/AnalyticsReport/index.html +36 -37
- package/app/m/approvals/ApprovalEvent/index.html +36 -37
- package/app/m/approvals/ApprovalPolicy/index.html +36 -37
- package/app/m/approvals/ApprovalRequest/index.html +36 -37
- package/app/m/assets/Asset/attachments/index.html +38 -39
- package/app/m/assets/Asset/index.html +36 -37
- package/app/m/assets/AssetAssociation/index.html +36 -37
- package/app/m/assets/AssetMetafield/index.html +36 -37
- package/app/m/assets/AssetStatus/index.html +36 -37
- package/app/m/assets/AssetType/index.html +36 -37
- package/app/m/assets/Folder/index.html +36 -37
- package/app/m/chat/AgentSession/index.html +36 -37
- package/app/m/chat/ChatMessage/index.html +36 -37
- package/app/m/chat/ChatParticipant/index.html +36 -37
- package/app/m/chat/ChatReaction/index.html +36 -37
- package/app/m/chat/ChatRoom/index.html +36 -37
- package/app/m/chat/ChatThread/index.html +36 -37
- package/app/m/chat/VoiceGatewayTurn/index.html +36 -37
- package/app/m/chat/VoiceSession/index.html +36 -37
- package/app/m/commerce/Agreement/index.html +36 -37
- package/app/m/commerce/Cart/index.html +36 -37
- package/app/m/commerce/Contract/index.html +36 -37
- package/app/m/commerce/ContractLineItem/index.html +36 -37
- package/app/m/commerce/Customer/index.html +36 -37
- package/app/m/commerce/DocumentTax/index.html +36 -37
- package/app/m/commerce/Estimate/index.html +36 -37
- package/app/m/commerce/Fulfillment/index.html +36 -37
- package/app/m/commerce/FulfillmentLineItem/index.html +36 -37
- package/app/m/commerce/HistoricalCustomerFunds/index.html +36 -37
- package/app/m/commerce/HistoricalCustomerFundsAllocation/index.html +36 -37
- package/app/m/commerce/HistoricalSalesLine/index.html +36 -37
- package/app/m/commerce/Invoice/index.html +36 -37
- package/app/m/commerce/InvoiceLineItem/index.html +36 -37
- package/app/m/commerce/Lease/index.html +36 -37
- package/app/m/commerce/LicenseSale/index.html +36 -37
- package/app/m/commerce/Order/index.html +36 -37
- package/app/m/commerce/Payment/index.html +36 -37
- package/app/m/commerce/PaymentAllocation/index.html +36 -37
- package/app/m/commerce/PaymentInstrument/index.html +36 -37
- package/app/m/commerce/PaymentIntent/index.html +36 -37
- package/app/m/commerce/Payout/index.html +36 -37
- package/app/m/commerce/ProductionOrder/index.html +36 -37
- package/app/m/commerce/PurchaseContract/index.html +36 -37
- package/app/m/commerce/PurchaseOrder/index.html +36 -37
- package/app/m/commerce/SalesContract/index.html +36 -37
- package/app/m/commerce/SupplierQuote/index.html +36 -37
- package/app/m/commerce/TaxCode/index.html +36 -37
- package/app/m/commerce/TaxComponent/index.html +36 -37
- package/app/m/commerce/TaxSettings/index.html +36 -37
- package/app/m/commerce/TaxSummaryReport/index.html +36 -37
- package/app/m/commerce/Vendor/index.html +36 -37
- package/app/m/commerce/WholesaleOrder/index.html +36 -37
- package/app/m/content/Content/index.html +36 -37
- package/app/m/content/ContentContribution/index.html +36 -37
- package/app/m/content/ContentContributionAttachment/index.html +36 -37
- package/app/m/content/ContentContributionRevision/index.html +36 -37
- package/app/m/content/ContentContributionType/index.html +36 -37
- package/app/m/content/ContentContributor/index.html +36 -37
- package/app/m/content/ContentCorrection/index.html +36 -37
- package/app/m/content/ContentFeedSource/index.html +36 -37
- package/app/m/content/ContentGovernanceAssignment/index.html +36 -37
- package/app/m/content/ContentGovernancePolicy/index.html +36 -37
- package/app/m/content/ContentGovernanceProfile/index.html +36 -37
- package/app/m/content/ContentReference/index.html +36 -37
- package/app/m/content/ContentReview/index.html +36 -37
- package/app/m/content/ContentVersion/index.html +36 -37
- package/app/m/events/Event/index.html +36 -37
- package/app/m/events/EventParticipant/index.html +36 -37
- package/app/m/events/EventSeries/index.html +36 -37
- package/app/m/events/EventType/index.html +36 -37
- package/app/m/expenses/Expense/index.html +36 -37
- package/app/m/facts/Fact/index.html +36 -37
- package/app/m/facts/FactContent/index.html +36 -37
- package/app/m/facts/FactEvidence/index.html +36 -37
- package/app/m/facts/FactSource/index.html +36 -37
- package/app/m/facts/FactSubject/index.html +36 -37
- package/app/m/facts/FactTag/index.html +36 -37
- package/app/m/fields/FieldPolicy/index.html +36 -37
- package/app/m/fields/FieldPolicySuggestion/index.html +36 -37
- package/app/m/fields/FieldUsageCounter/index.html +36 -37
- package/app/m/images/Image/index.html +36 -37
- package/app/m/inventory/InventoryLocation/index.html +36 -37
- package/app/m/inventory/StockLevel/index.html +36 -37
- package/app/m/inventory/StockMovement/index.html +36 -37
- package/app/m/ledgers/Account/index.html +36 -37
- package/app/m/ledgers/Journal/index.html +36 -37
- package/app/m/ledgers/JournalEntry/index.html +36 -37
- package/app/m/ledgers/Ledger/index.html +36 -37
- package/app/m/manufacturing/Assembly/index.html +36 -37
- package/app/m/manufacturing/BillOfMaterials/index.html +36 -37
- package/app/m/manufacturing/BomLine/index.html +36 -37
- package/app/m/manufacturing/Operation/index.html +36 -37
- package/app/m/manufacturing/ProductionRun/index.html +36 -37
- package/app/m/manufacturing/ProductionRunCompletion/index.html +36 -37
- package/app/m/manufacturing/RoutingStep/index.html +36 -37
- package/app/m/marketing/Campaign/index.html +36 -37
- package/app/m/marketing/CampaignChannel/index.html +36 -37
- package/app/m/marketing/CampaignMetricSnapshot/index.html +36 -37
- package/app/m/messages/Account/index.html +36 -37
- package/app/m/messages/Attachment/index.html +36 -37
- package/app/m/messages/Blacklist/index.html +36 -37
- package/app/m/messages/Email/failed-sends/index.html +38 -39
- package/app/m/messages/Email/index.html +36 -37
- package/app/m/messages/Email/mailbox/index.html +38 -39
- package/app/m/messages/EmailAccount/index.html +36 -37
- package/app/m/messages/EmailAttachment/index.html +36 -37
- package/app/m/messages/EmailFolder/index.html +36 -37
- package/app/m/messages/Message/index.html +36 -37
- package/app/m/messages/MessagingEndpoint/index.html +36 -37
- package/app/m/messages/PersonaMessageRoute/index.html +36 -37
- package/app/m/messages/SlackAccount/index.html +36 -37
- package/app/m/messages/SlackMessage/index.html +36 -37
- package/app/m/messages/TelegramAccount/index.html +36 -37
- package/app/m/messages/Tweet/index.html +36 -37
- package/app/m/messages/TwitterAccount/index.html +36 -37
- package/app/m/messages/Whitelist/index.html +36 -37
- package/app/m/messages/ZulipAccount/index.html +36 -37
- package/app/m/places/Place/index.html +36 -37
- package/app/m/places/PlaceType/index.html +36 -37
- package/app/m/products/Category/index.html +36 -37
- package/app/m/products/Material/index.html +36 -37
- package/app/m/products/Product/index.html +36 -37
- package/app/m/products/Product/ingredients/index.html +38 -39
- package/app/m/products/ProductVariant/index.html +36 -37
- package/app/m/products/Sku/index.html +36 -37
- package/app/m/profiles/ApiKey/index.html +36 -37
- package/app/m/profiles/Bot/index.html +36 -37
- package/app/m/profiles/MagicLinkToken/index.html +36 -37
- package/app/m/profiles/NostrIdentity/index.html +36 -37
- package/app/m/profiles/OidcIdentity/index.html +36 -37
- package/app/m/profiles/Organization/index.html +36 -37
- package/app/m/profiles/Person/index.html +36 -37
- package/app/m/profiles/Profile/index.html +36 -37
- package/app/m/profiles/ProfileMetadata/index.html +36 -37
- package/app/m/profiles/ProfileMetafield/index.html +36 -37
- package/app/m/profiles/ProfileRelationship/index.html +36 -37
- package/app/m/profiles/ProfileRelationshipTerm/index.html +36 -37
- package/app/m/profiles/ProfileRelationshipType/index.html +36 -37
- package/app/m/profiles/ProfileType/index.html +36 -37
- package/app/m/projects/Comment/index.html +36 -37
- package/app/m/projects/Issue/index.html +36 -37
- package/app/m/projects/Label/index.html +36 -37
- package/app/m/projects/Project/index.html +36 -37
- package/app/m/projects/ProjectIntegration/index.html +36 -37
- package/app/m/projects/PullRequest/index.html +36 -37
- package/app/m/projects/Repository/index.html +36 -37
- package/app/m/properties/Property/index.html +36 -37
- package/app/m/properties/Zone/index.html +36 -37
- package/app/m/reports/RuntimeReport/index.html +39 -37
- package/app/m/reports/SmrtPrincipalReportRefreshTask/index.html +36 -37
- package/app/m/reports/SmrtReportLock/index.html +36 -37
- package/app/m/reports/SmrtReportRefreshTask/index.html +36 -37
- package/app/m/reports/SmrtReportRun/index.html +36 -37
- package/app/m/reports/SmrtReportSchedule/index.html +36 -37
- package/app/m/reports/SmrtReportWatermark/index.html +36 -37
- package/app/m/sales/Agreement/index.html +36 -37
- package/app/m/sales/AttributionException/index.html +36 -37
- package/app/m/sales/AttributionPolicy/index.html +36 -37
- package/app/m/sales/Commission/index.html +36 -37
- package/app/m/sales/CommissionAdjustment/index.html +36 -37
- package/app/m/sales/CommissionPayout/index.html +36 -37
- package/app/m/sales/CommissionPlan/index.html +36 -37
- package/app/m/sales/Earner/index.html +36 -37
- package/app/m/sales/EarnerSourceAttribution/index.html +36 -37
- package/app/m/sales/EarningEvent/index.html +36 -37
- package/app/m/sales/ExecutedAgreement/index.html +36 -37
- package/app/m/sales/Lead/index.html +36 -37
- package/app/m/sales/Opportunity/index.html +36 -37
- package/app/m/sales/OpportunityConversion/index.html +36 -37
- package/app/m/sales/PipelineDefinition/index.html +36 -37
- package/app/m/sales/PipelineStage/index.html +36 -37
- package/app/m/sales/Referral/index.html +36 -37
- package/app/m/sales/ReferralAgreement/index.html +36 -37
- package/app/m/sales/ReferralLink/index.html +36 -37
- package/app/m/sales/ReferralProgram/index.html +36 -37
- package/app/m/sales/ReferralTermSnapshot/index.html +36 -37
- package/app/m/sales/ReferralTouch/index.html +36 -37
- package/app/m/sales/Referrer/index.html +36 -37
- package/app/m/sales/SalesActivity/index.html +36 -37
- package/app/m/sales/SalesRepresentative/index.html +36 -37
- package/app/m/sites/Site/index.html +36 -37
- package/app/m/sites/SiteAgentBinding/index.html +36 -37
- package/app/m/social/OAuthState/index.html +36 -37
- package/app/m/social/SocialAccount/index.html +36 -37
- package/app/m/social/SocialPost/index.html +36 -37
- package/app/m/social/SocialPostAnalyticsSnapshot/index.html +36 -37
- package/app/m/subscriptions/BillingAdjustment/index.html +36 -37
- package/app/m/subscriptions/ClientCharge/index.html +36 -37
- package/app/m/subscriptions/CreditGrant/index.html +36 -37
- package/app/m/subscriptions/PricingRule/index.html +36 -37
- package/app/m/subscriptions/RetailCharge/index.html +36 -37
- package/app/m/subscriptions/SpendingPolicy/index.html +36 -37
- package/app/m/subscriptions/SubscriptionPlan/index.html +36 -37
- package/app/m/subscriptions/TenantSubscription/index.html +36 -37
- package/app/m/subscriptions/TenantUsageMetric/index.html +36 -37
- package/app/m/support/ServiceTimeEntry/index.html +36 -37
- package/app/m/support/SupportAiRun/index.html +36 -37
- package/app/m/support/SupportAvailability/index.html +36 -37
- package/app/m/support/SupportCase/index.html +36 -37
- package/app/m/support/SupportCaseEvent/index.html +36 -37
- package/app/m/support/SupportChannelBinding/index.html +36 -37
- package/app/m/support/SupportCharge/index.html +36 -37
- package/app/m/support/SupportCompensation/index.html +36 -37
- package/app/m/support/SupportCompensationPlan/index.html +36 -37
- package/app/m/support/SupportEscalation/index.html +36 -37
- package/app/m/support/SupportInteraction/index.html +36 -37
- package/app/m/support/SupportPlan/index.html +36 -37
- package/app/m/support/SupportPolicy/index.html +36 -37
- package/app/m/support/SupportQualification/index.html +36 -37
- package/app/m/support/SupportServiceTarget/index.html +36 -37
- package/app/m/support/SupportSpecialist/index.html +36 -37
- package/app/m/support/SupportWorkLink/index.html +36 -37
- package/app/m/tags/Tag/index.html +36 -37
- package/app/m/tags/TagAlias/index.html +36 -37
- package/app/m/timesheets/AttendanceBreak/index.html +36 -37
- package/app/m/timesheets/AttendancePunch/index.html +36 -37
- package/app/m/timesheets/AttendanceSegment/index.html +36 -37
- package/app/m/timesheets/ServiceChargeSnapshot/index.html +36 -37
- package/app/m/timesheets/ServiceCompensationSnapshot/index.html +36 -37
- package/app/m/timesheets/ServiceTimeEntry/index.html +36 -37
- package/app/m/users/Group/index.html +36 -37
- package/app/m/users/GroupMember/index.html +36 -37
- package/app/m/users/GroupRole/index.html +36 -37
- package/app/m/users/Membership/index.html +36 -37
- package/app/m/users/MembershipOverride/index.html +36 -37
- package/app/m/users/Permission/index.html +36 -37
- package/app/m/users/Role/index.html +36 -37
- package/app/m/users/RolePermission/index.html +36 -37
- package/app/m/users/Session/index.html +36 -37
- package/app/m/users/Tenant/index.html +36 -37
- package/app/m/users/TenantIntegration/index.html +36 -37
- package/app/m/users/TenantPermissionOverride/index.html +36 -37
- package/app/m/users/User/index.html +36 -37
- package/app/m/video/Character/index.html +36 -37
- package/app/m/video/CharacterAsset/index.html +36 -37
- package/app/m/video/CompositeJob/index.html +36 -37
- package/app/m/video/Performer/index.html +36 -37
- package/app/m/video/PerformerAsset/index.html +36 -37
- package/app/m/video/Scene/index.html +36 -37
- package/app/m/video/SceneAsset/index.html +36 -37
- package/app/m/video/VideoComposition/index.html +36 -37
- package/app/m/video/VideoCompositionAsset/index.html +36 -37
- package/app/m/video/VideoSequence/index.html +36 -37
- package/app/m/video/VideoSequenceAsset/index.html +36 -37
- package/app/m/video/VideoShot/index.html +36 -37
- package/app/m/video/VideoShotAsset/index.html +36 -37
- package/app/m/video/VideoShotCharacter/index.html +36 -37
- package/app/m/video/VideoWorkflow/index.html +36 -37
- package/app/m/voice/VoiceOutput/index.html +36 -37
- package/app/m/voice/VoiceProfile/index.html +36 -37
- package/app/m/voice/VoiceSample/index.html +36 -37
- package/app/mcp.html +2 -2
- package/app/packages/ads/index.html +30 -33
- package/app/packages/analytics/index.html +30 -33
- package/app/packages/approvals/index.html +30 -33
- package/app/packages/assets/index.html +30 -33
- package/app/packages/chat/index.html +30 -33
- package/app/packages/comments/index.html +30 -33
- package/app/packages/commerce/index.html +30 -33
- package/app/packages/content/index.html +30 -33
- package/app/packages/events/index.html +30 -33
- package/app/packages/expenses/index.html +30 -33
- package/app/packages/facts/index.html +30 -33
- package/app/packages/fields/index.html +30 -33
- package/app/packages/human-resources/index.html +30 -33
- package/app/packages/images/index.html +30 -33
- package/app/packages/index.html +30 -33
- package/app/packages/ingestion/index.html +30 -33
- package/app/packages/inventory/index.html +30 -33
- package/app/packages/ledgers/index.html +30 -33
- package/app/packages/manufacturing/index.html +30 -33
- package/app/packages/marketing/index.html +30 -33
- package/app/packages/messages/index.html +30 -33
- package/app/packages/places/index.html +30 -33
- package/app/packages/preferences/index.html +30 -33
- package/app/packages/products/index.html +30 -33
- package/app/packages/profiles/index.html +30 -33
- package/app/packages/projects/index.html +30 -33
- package/app/packages/properties/index.html +30 -33
- package/app/packages/reports/index.html +30 -33
- package/app/packages/sales/index.html +30 -33
- package/app/packages/sites/index.html +30 -33
- package/app/packages/social/index.html +30 -33
- package/app/packages/subscriptions/index.html +30 -33
- package/app/packages/support/index.html +30 -33
- package/app/packages/tags/index.html +30 -33
- package/app/packages/timesheets/index.html +30 -33
- package/app/packages/users/index.html +30 -33
- package/app/packages/video/index.html +30 -33
- package/app/packages/voice/index.html +30 -33
- package/app/packages/webhooks/index.html +30 -33
- package/app/recipes/account-access/help/index.html +32 -35
- package/app/recipes/account-access/index.html +36 -38
- package/app/recipes/activity/help/index.html +32 -35
- package/app/recipes/activity/index.html +36 -38
- package/app/recipes/agreements/help/index.html +32 -35
- package/app/recipes/agreements/index.html +36 -38
- package/app/recipes/analytics.reports/help/index.html +32 -35
- package/app/recipes/analytics.reports/index.html +36 -38
- package/app/recipes/assets/help/index.html +32 -35
- package/app/recipes/assets/index.html +36 -38
- package/app/recipes/billing/help/index.html +32 -35
- package/app/recipes/billing/index.html +36 -38
- package/app/recipes/chat.assistant/help/index.html +32 -35
- package/app/recipes/chat.assistant/index.html +36 -38
- package/app/recipes/comments/help/index.html +32 -35
- package/app/recipes/comments/index.html +36 -38
- package/app/recipes/commerce.customers/help/index.html +32 -35
- package/app/recipes/commerce.customers/index.html +36 -38
- package/app/recipes/commerce.estimates/help/index.html +32 -35
- package/app/recipes/commerce.estimates/index.html +36 -38
- package/app/recipes/commerce.purchases/help/index.html +32 -35
- package/app/recipes/commerce.purchases/index.html +36 -38
- package/app/recipes/commerce.sales/help/index.html +32 -35
- package/app/recipes/commerce.sales/index.html +36 -38
- package/app/recipes/commerce.vendors/help/index.html +32 -35
- package/app/recipes/commerce.vendors/index.html +36 -38
- package/app/recipes/commerce.wholesale/help/index.html +32 -35
- package/app/recipes/commerce.wholesale/index.html +36 -38
- package/app/recipes/events.calendar/help/index.html +32 -35
- package/app/recipes/events.calendar/index.html +36 -38
- package/app/recipes/expenses.tracking/help/index.html +32 -35
- package/app/recipes/expenses.tracking/index.html +36 -38
- package/app/recipes/fields.form-customization/help/index.html +32 -35
- package/app/recipes/fields.form-customization/index.html +36 -38
- package/app/recipes/ingestion/help/index.html +32 -35
- package/app/recipes/ingestion/index.html +36 -38
- package/app/recipes/integrations/help/index.html +32 -35
- package/app/recipes/integrations/index.html +36 -38
- package/app/recipes/inventory.stock/help/index.html +32 -35
- package/app/recipes/inventory.stock/index.html +36 -38
- package/app/recipes/ledgers.bookkeeping/help/index.html +32 -35
- package/app/recipes/ledgers.bookkeeping/index.html +36 -38
- package/app/recipes/messages/help/index.html +32 -35
- package/app/recipes/messages/index.html +36 -38
- package/app/recipes/products/help/index.html +32 -35
- package/app/recipes/products/index.html +36 -38
- package/app/recipes/projects.tracker/help/index.html +32 -35
- package/app/recipes/projects.tracker/index.html +36 -38
- package/app/recipes/reports.materialized/help/index.html +32 -35
- package/app/recipes/reports.materialized/index.html +36 -38
- package/app/recipes/reports.runtime/help/index.html +32 -35
- package/app/recipes/reports.runtime/index.html +37 -39
- package/app/recipes/sales.pipeline/help/index.html +32 -35
- package/app/recipes/sales.pipeline/index.html +36 -38
- package/app/recipes/tags.taxonomy/help/index.html +32 -35
- package/app/recipes/tags.taxonomy/index.html +36 -38
- package/app/recipes/team-collaboration/help/index.html +32 -35
- package/app/recipes/team-collaboration/index.html +36 -38
- package/app/recipes/timesheets.time-entries/help/index.html +32 -35
- package/app/recipes/timesheets.time-entries/index.html +36 -38
- package/app/s/custom-accounts/index.html +29 -32
- package/app/s/custom-appointments/index.html +29 -32
- package/app/s/custom-billing/index.html +29 -32
- package/app/s/custom-bookings/index.html +79 -0
- package/app/s/custom-buying/index.html +29 -32
- package/app/s/custom-checkout/index.html +29 -32
- package/app/s/custom-classes/index.html +29 -32
- package/app/s/custom-clients/index.html +29 -32
- package/app/s/custom-events/index.html +29 -32
- package/app/s/custom-fleet/index.html +29 -32
- package/app/s/custom-gigs/index.html +79 -0
- package/app/s/custom-giving/index.html +29 -32
- package/app/s/custom-instruments/index.html +79 -0
- package/app/s/custom-jobs/index.html +29 -32
- package/app/s/custom-kitchen/index.html +29 -32
- package/app/s/custom-lessons/index.html +79 -0
- package/app/s/custom-material/index.html +29 -32
- package/app/s/custom-meetings/index.html +29 -32
- package/app/s/custom-members/index.html +29 -32
- package/app/s/custom-merch/index.html +79 -0
- package/app/s/custom-money/index.html +79 -0
- package/app/s/custom-paint/index.html +29 -32
- package/app/s/custom-parts/index.html +29 -32
- package/app/s/custom-rentals/index.html +29 -32
- package/app/s/custom-roastery/index.html +29 -32
- package/app/s/custom-schedule/index.html +29 -32
- package/app/s/custom-shelf/index.html +29 -32
- package/app/s/custom-shop/index.html +29 -32
- package/app/s/custom-students/index.html +79 -0
- package/app/s/custom-wholesale/index.html +29 -32
- package/app/s/custom-work/index.html +29 -32
- package/app/s/custom-yard/index.html +29 -32
- package/app/s/section-access-control/index.html +29 -32
- package/app/s/section-account-security/index.html +29 -32
- package/app/s/section-accounting/index.html +29 -32
- package/app/s/section-activity/index.html +29 -32
- package/app/s/section-agreements/index.html +29 -32
- package/app/s/section-analytics/index.html +29 -32
- package/app/s/section-assets/index.html +29 -32
- package/app/s/section-billing/index.html +29 -32
- package/app/s/section-calendar/index.html +29 -32
- package/app/s/section-catalog/index.html +29 -32
- package/app/s/section-chat.assistant/index.html +29 -32
- package/app/s/section-comments/index.html +29 -32
- package/app/s/section-fields.form-customization/index.html +29 -32
- package/app/s/section-ingestion/index.html +29 -32
- package/app/s/section-integrations/index.html +29 -32
- package/app/s/section-messages/index.html +29 -32
- package/app/s/section-more/index.html +29 -32
- package/app/s/section-operations/index.html +29 -32
- package/app/s/section-projects/index.html +29 -32
- package/app/s/section-purchasing/index.html +29 -32
- package/app/s/section-reports.materialized/index.html +29 -32
- package/app/s/section-reports.runtime/index.html +29 -32
- package/app/s/section-sales/index.html +29 -32
- package/app/s/section-taxonomy/index.html +29 -32
- package/app/s/section-team/index.html +29 -32
- package/app/s/section-work/index.html +29 -32
- package/dist/assistant/change.d.ts +10 -1
- package/dist/assistant/change.d.ts.map +1 -1
- package/dist/assistant/change.js +6 -1
- package/dist/assistant/prompt.d.ts +10 -1
- package/dist/assistant/prompt.d.ts.map +1 -1
- package/dist/assistant/prompt.js +42 -7
- package/dist/assistant/session.svelte.d.ts +6 -0
- package/dist/assistant/session.svelte.d.ts.map +1 -1
- package/dist/assistant/session.svelte.js +6 -0
- package/dist/assistant/transport.d.ts +23 -3
- package/dist/assistant/transport.d.ts.map +1 -1
- package/dist/assistant/transport.js +356 -13
- package/dist/catalog/catalog.json +107 -41
- package/dist/components/BrowserAssistant.svelte +26 -0
- package/dist/components/BrowserAssistant.svelte.d.ts.map +1 -1
- package/dist/components/ModelPage.svelte +36 -4
- package/dist/components/ModelPage.svelte.d.ts.map +1 -1
- package/dist/components/PlannerReports.svelte +61 -0
- package/dist/components/PlannerReports.svelte.d.ts +10 -0
- package/dist/components/PlannerReports.svelte.d.ts.map +1 -0
- package/dist/components/PlannerSavedReportsWidget.svelte +38 -0
- package/dist/components/PlannerSavedReportsWidget.svelte.d.ts +9 -0
- package/dist/components/PlannerSavedReportsWidget.svelte.d.ts.map +1 -0
- package/dist/components/ReportProposalCard.svelte +63 -0
- package/dist/components/ReportProposalCard.svelte.d.ts +17 -0
- package/dist/components/ReportProposalCard.svelte.d.ts.map +1 -0
- package/dist/components/SectionOverview.svelte +22 -1
- package/dist/components/SectionOverview.svelte.d.ts.map +1 -1
- package/dist/components/ThemeBridge.svelte +2 -2
- package/dist/core/prompt.d.ts.map +1 -1
- package/dist/core/prompt.js +7 -1
- package/dist/core/reply.d.ts +6 -0
- package/dist/core/reply.d.ts.map +1 -1
- package/dist/core/reply.js +11 -0
- package/dist/data/packs.d.ts.map +1 -1
- package/dist/data/packs.js +415 -0
- package/dist/data/planner-source.d.ts.map +1 -1
- package/dist/data/planner-source.js +4 -1
- package/dist/library/icons.d.ts.map +1 -1
- package/dist/library/icons.js +10 -0
- package/dist/library/library.json +506 -0
- package/dist/overviews/definitions.d.ts.map +1 -1
- package/dist/overviews/definitions.js +6 -1
- package/dist/overviews/registry.d.ts.map +1 -1
- package/dist/overviews/registry.js +9 -5
- package/dist/planner/Planner.svelte +17 -0
- package/dist/planner/Planner.svelte.d.ts.map +1 -1
- package/dist/planner/instance.d.ts +6 -0
- package/dist/planner/instance.d.ts.map +1 -1
- package/dist/planner/shell.d.ts.map +1 -1
- package/dist/planner/shell.js +3 -1
- package/dist/reports/intent.d.ts +106 -0
- package/dist/reports/intent.d.ts.map +1 -0
- package/dist/reports/intent.js +667 -0
- package/dist/reports/planner.d.ts +33 -0
- package/dist/reports/planner.d.ts.map +1 -0
- package/dist/reports/planner.js +60 -0
- package/dist/reports/sources.d.ts +36 -0
- package/dist/reports/sources.d.ts.map +1 -0
- package/dist/reports/sources.js +125 -0
- package/dist/reports/store.d.ts +64 -0
- package/dist/reports/store.d.ts.map +1 -0
- package/dist/reports/store.js +214 -0
- package/dist/smrt-version.d.ts +1 -1
- package/dist/smrt-version.js +1 -1
- package/package.json +54 -54
- package/app/_app/immutable/assets/0.C8CwV4Fz.css +0 -1
- package/app/_app/immutable/assets/AppShell.Dnc9PAvY.css +0 -1
- package/app/_app/immutable/assets/app.4ScdTV_S.css +0 -1
- package/app/_app/immutable/assets/labels.DrQMsG17.css +0 -1
- package/app/_app/immutable/assets/state.CkVocVUJ.css +0 -1
- package/app/_app/immutable/chunks/9pRTae44.js +0 -1
- package/app/_app/immutable/chunks/BhU_yBI_.js +0 -1
- package/app/_app/immutable/chunks/Bsn3IIve.js +0 -4
- package/app/_app/immutable/chunks/C_3CJO_1.js +0 -1
- package/app/_app/immutable/chunks/Cr4byQts.js +0 -24
- package/app/_app/immutable/chunks/CtjBwCj8.js +0 -1
- package/app/_app/immutable/chunks/CyUSxz1P.js +0 -4
- package/app/_app/immutable/chunks/J9kOiFLO.js +0 -11
- package/app/_app/immutable/chunks/M-CuJzQN.js +0 -1
- package/app/_app/immutable/chunks/NppCG--v.js +0 -1
- package/app/_app/immutable/chunks/O8DAZ_le.js +0 -1
- package/app/_app/immutable/chunks/d_dqmeIr.js +0 -1
- package/app/_app/immutable/chunks/gMSmS-_y.js +0 -2
- package/app/_app/immutable/entry/app.B4gMiHwR.js +0 -2
- package/app/_app/immutable/entry/start.BXkBl20Z.js +0 -1
- package/app/_app/immutable/nodes/0.2MYMg80l.js +0 -9
- package/app/_app/immutable/nodes/14.B6TD25VU.js +0 -1
- package/app/_app/immutable/nodes/2.x9WyxQ1S.js +0 -24
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./COiEfhsA.js";import{
|
|
1
|
+
import{n as e}from"./COiEfhsA.js";import{S as t}from"./CsaWd8kG.js";import{a as n,r}from"./C7zBd-pD.js";import{t as i}from"./CA-A9Ngs.js";function a(e){return t=>{t.allowLocalModels=e,t.useBrowserCache=!0;let n=globalThis.crossOriginIsolated===!0,r=t.backends?.onnx?.wasm;r&&!n&&(r.numThreads=1)}}var o=`onnx-community/whisper-tiny.en`,s={"moonshine-tiny":{id:`onnx-community/moonshine-tiny-ONNX`,bytes:322e5,englishOnly:!0,label:`Moonshine tiny`},"moonshine-base":{id:`onnx-community/moonshine-base-ONNX`,bytes:67e6,englishOnly:!0,label:`Moonshine base`},"whisper-tiny.en":{id:o,bytes:451e5,englishOnly:!0,label:`Whisper tiny (English)`},"whisper-base.en":{id:`onnx-community/whisper-base.en`,bytes:85e6,englishOnly:!0,label:`Whisper base (English)`},"whisper-small.en":{id:`onnx-community/whisper-small.en`,bytes:26e7,englishOnly:!0,label:`Whisper small (English)`}};function c(e){return e?s[e]?.id??e:o}function l(e){return Object.values(s).some(t=>t.id===e&&t.englishOnly)||/\.en$|moonshine/i.test(e)}var u=`audio/pcm;rate=16000;channels=1;encoding=f32le`;function d(){let e=Error(`Download cancelled`);return e.name=`AbortError`,e}function f(e){return e?.split(/[-_]/)[0]?.toLowerCase()||void 0}function p(e){return{data:new Uint8Array(e.slice().buffer),mimeType:u}}async function m(e){try{return await(e?e():i(`@happyvertical/speech/local`))}catch{throw new r(`local-speech`,'@happyvertical/speech could not be loaded. Install it (and @huggingface/transformers) and pass `loadSpeech: () => import("@happyvertical/speech/local")`.')}}var h=class{createWorker;loadSpeech;progress;worker=null;client=null;constructor(e,t,n){this.createWorker=e,this.loadSpeech=t,this.progress=n}ensure(){return this.client??=m(this.loadSpeech).then(e=>{let t=this.createWorker();return this.worker=t,new e.LocalTranscriberWorkerClient(t,{onProgress:this.progress})}),this.client}async isCached(e){return(await this.ensure()).isCached(e)}async preload(e,t){if(t?.aborted)throw d();let n=await this.ensure();if(!t)return n.preload(e);let r=()=>this.dispose();t.addEventListener(`abort`,r,{once:!0});try{await Promise.race([n.preload(e),new Promise((e,n)=>t.addEventListener(`abort`,()=>n(d()),{once:!0}))])}finally{t.removeEventListener(`abort`,r)}}async transcribe(e,t,n){return(await(await this.ensure()).transcribe({audio:p(e),model:t,language:f(n)})).text.trim()}dispose(){this.client?.then(e=>e.close()).catch(()=>void 0),this.worker?.terminate(),this.worker=null,this.client=null}},g=class{options;model;progress;transcriber=null;constructor(e,t,n){this.options=e,this.model=t,this.progress=n}ensure(){return this.transcriber??=m(this.options.loadSpeech).then(e=>new e.LocalTranscriber({model:this.model,device:this.options.device??`auto`,dtype:this.options.dtype??`q8`,...this.options.loadModule?{transformers:this.options.loadModule}:{},onProgress:this.progress,configureEnv:a(this.options.allowLocalModels??!1)})),this.transcriber}async isCached(e){return(await this.ensure()).isCached(e)}async preload(e,t){if(t?.aborted)throw d();await(await this.ensure()).preload(e,t).catch(e=>{throw t?.aborted?d():e})}async transcribe(e,t,n){return(await(await this.ensure()).transcribe({audio:p(e),model:t,language:f(n)})).text.trim()}dispose(){this.transcriber?.then(e=>e.dispose()).catch(()=>void 0),this.transcriber=null}},_=class{options;modelId;backend=null;loadPromise=null;listeners=new Set;_state=`idle`;constructor(e={}){this.options=e,this.modelId=c(e.model??e.modelId)}get state(){return this._state}get ready(){return this._state===`ready`}get englishOnly(){return l(this.modelId)}estimateSize(){return Object.values(s).find(e=>e.id===this.modelId)?.bytes??451e5}emit(e){for(let t of this.listeners)t(e)}onEngineProgress=e=>{if(e.status!==`progress_total`||typeof e.loaded!=`number`||typeof e.total!=`number`)return;let t=this.estimateSize(),n=e.total||t,r=e.total>0&&e.loaded>=e.total;this.emit({state:r?`extracting`:`downloading`,bytesLoaded:e.loaded,bytesTotal:n,percent:e.total?Math.round(e.loaded/e.total*100):0,currentFile:e.file})};getBackend(){if(this.backend)return this.backend;let{createWorker:e,loadSpeech:t}=this.options;return this.backend=e?new h(e,t,this.onEngineProgress):new g(this.options,this.modelId,this.onEngineProgress),this.backend}async isCached(){if(this._state===`ready`)return!0;try{return await this.getBackend().isCached(this.modelId)}catch{return!1}}load(e={}){let{onProgress:t,signal:n}=e;if(this._state===`ready`)return Promise.resolve();if(t&&this.listeners.add(t),!this.loadPromise){this._state=`loading`;let e=this.estimateSize();this.emit({state:`downloading`,bytesLoaded:0,bytesTotal:e,percent:0}),this.loadPromise=this.getBackend().preload(this.modelId,n).then(()=>{this._state=`ready`,this.emit({state:`complete`,bytesLoaded:e,bytesTotal:e,percent:100})}).catch(t=>{this._state=`idle`,this.backend?.dispose(),this.backend=null;let n=t instanceof Error?t:Error(String(t));throw n.name!==`AbortError`&&(this._state=`error`,this.emit({state:`error`,bytesLoaded:0,bytesTotal:e,percent:0,error:n.message})),n}).finally(()=>{this.loadPromise=null,this.listeners.clear()})}let r=this.loadPromise;return n?new Promise((e,t)=>{if(n.aborted)return t(d());n.addEventListener(`abort`,()=>t(d()),{once:!0}),r.then(e,t)}):r}transcribe(e,t){return this._state===`ready`?this.getBackend().transcribe(e,this.modelId,t):Promise.reject(Error(`The speech model is not loaded`))}dispose(){this.backend?.dispose(),this.backend=null,this.loadPromise=null,this.listeners.clear(),this._state=`idle`}};function v(e={}){return new _(e)}var y=e({LocalSpeechSTTAdapter:()=>w,WhisperLocalSTTAdapter:()=>w,WhisperWasmSTTAdapter:()=>w}),b={tiny:`onnx-community/whisper-tiny.en`,base:`onnx-community/whisper-base.en`,small:`onnx-community/whisper-small.en`},x=16e3,S=9e4;async function C(e){let t=await e.arrayBuffer(),n=new AudioContext({sampleRate:x});try{return(await n.decodeAudioData(t)).getChannelData(0).slice()}finally{n.close().catch(()=>void 0)}}var w=class{type;stopTimeoutMs=S;options;_model;makeCapture;capture=null;captureOff=null;_isListening=!1;language=`en`;session=0;starting=!1;stopping=null;resultListeners=new Set;errorListeners=new Set;startListeners=new Set;endListeners=new Set;constructor(e={}){this.options={type:`whisper-local`,defaultLanguage:`en`,...e},this.type=this.options.type,this.language=this.options.defaultLanguage??`en`,this.makeCapture=e.capture??t;let n=this.options.model??this.options.modelId??(this.options.modelSize?b[this.options.modelSize]:this.type===`moonshine`?`moonshine-tiny`:void 0);this._model=this.options.modelHandle??v({model:n,device:this.options.device,dtype:this.options.dtype,createWorker:this.options.createWorker,loadSpeech:this.options.loadSpeech,loadModule:this.options.loadModule,allowLocalModels:this.options.allowLocalModels})}get model(){return this._model}get initState(){switch(this._model.state){case`ready`:return`ready`;case`loading`:return`initializing`;case`error`:return`error`;default:return`uninitialized`}}estimateSize(){return this._model.estimateSize()}isCached(){return this._model.isCached()}load(e){return this._model.load(e)}async ensureInitialized(e){await this._model.load({onProgress:e??this.options.onProgress})}async prepare(){if(this._model.state!==`ready`){if(!await this._model.isCached())throw new n(this._model.modelId,this.type);await this.ensureInitialized()}}getCapabilities(){return{continuous:!1,interimResults:!1,languages:this._model.englishOnly?[`en`]:[`en`,`es`,`fr`,`de`,`it`,`pt`,`nl`,`pl`,`ru`,`zh`,`ja`,`ko`],accuracy:`medium`,requiresDownload:!0,downloadSize:this._model.estimateSize()}}async transcribePcm(e,t={}){return await this.prepare(),this._model.transcribe(e,t.language??this.options.defaultLanguage??`en`)}async start(e={}){if(this._isListening||this.starting)return;let t=++this.session;this.starting=!0;try{await this.prepare()}finally{this.starting=!1}if(t!==this.session||this._isListening)return;this.language=e.language??this.options.defaultLanguage??`en`;let n=this.makeCapture({maxDurationMs:this.options.maxDurationMs});try{await n.start()}catch(e){let t=e instanceof Error?e:Error(String(e));throw this.emitError(t),t}if(t!==this.session)n.cancel();else{this.capture=n,this.captureOff=n.onLimit(e=>{e===`time`?this.stop():(this.captureOff?.(),this.finish(t,null,Error(`The recording is too long`)))}),this._isListening=!0;for(let e of this.startListeners)e()}}stop(){if(this.stopping)return this.stopping;let e=this.capture;if(this.starting&&this.session++,!e||!this._isListening)return Promise.resolve();let t=this.session;return this.stopping=(async()=>{let n=null,r=null;try{let r=await e.stop();if(t!==this.session)return;let i=await C(r.audio);n=await this._model.transcribe(i,this.language)}catch(e){r=e instanceof Error?e:Error(String(e))}await this.finish(t,n,r)})(),this.stopping}async finish(e,t,n){if(e===this.session){if(this.captureOff?.(),this.captureOff=null,this.capture=null,this._isListening=!1,this.stopping=null,n)this.emitError(n);else if(t){let e={text:t,confidence:1,isFinal:!0,timestamp:Date.now()};for(let t of this.resultListeners)t(e)}for(let e of this.endListeners)e()}}emitError(e){for(let t of this.errorListeners)t(e)}abort(){if(this.starting&&this.session++,this._isListening){this.session++,this.captureOff?.(),this.captureOff=null,this.capture?.cancel(),this.capture=null,this._isListening=!1,this.stopping=null;for(let e of this.endListeners)e()}}isListening(){return this._isListening}onResult(e){return this.resultListeners.add(e),()=>this.resultListeners.delete(e)}onError(e){return this.errorListeners.add(e),()=>this.errorListeners.delete(e)}onStart(e){return this.startListeners.add(e),()=>this.startListeners.delete(e)}onEnd(e){return this.endListeners.add(e),()=>this.endListeners.delete(e)}async dispose(){this.abort(),this.options.modelHandle||this._model.dispose(),this.resultListeners.clear(),this.errorListeners.clear(),this.startListeners.clear(),this.endListeners.clear()}};export{s as n,v as r,y as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,A as t,B as n,D as r,E as i,G as a,K as o,M as s,N as c,P as l,S as u,T as d,U as f,V as p,W as m,X as h,Y as g,Z as _,ct as ee,et as v,ft as y,it as te,j as ne,k as b,nt as x,ot as re,rt as S,tt as C,w,x as T,y as E}from"./BG9Gz_25.js";var D=e=>{let t=y(e);if(!t)throw Error(`The catalog has no model ${e}`);return t.model};function O(e){return String(e??``).toUpperCase().replace(/[^A-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}var k=/\{([A-Za-z_][\w]*\.[A-Za-z_][\w]*)(?:\|(slug))?\}/g;function A(e,t){return e.replace(k,(e,n,r)=>{let i=t[n],a=i==null?``:String(i);return r===`slug`?O(a):a})}function j(e,t,n=e=>e){return typeof e==`string`?A(e,t):typeof e==`object`&&e?{ref:n(e.ref),...e.field?{field:e.field}:{}}:e}function M(e,t,n){return Object.fromEntries(Object.entries(e??{}).map(([e,r])=>[e,j(r,t,n)]))}function N(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:null}function P(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=F(e.to);return r.alias===t?[[r.field,N(n[e.id])]]:[]}))}function F(e){let t=e.indexOf(`.`);if(t<1||t===e.length-1)throw Error(`A form field maps to "alias.field", got "${e}"`);return{alias:e.slice(0,t),field:e.slice(t+1)}}function I(e,t,n){let{alias:r,field:i}=F(e.to),a=t.find(e=>e.as===r);if(!a)throw Error(`Form field ${e.id} maps to unknown ${r}`);let o=n(a.model).fields.find(e=>e.name===i);if(!o)throw Error(`${a.model} has no field ${i} (form field ${e.id})`);return o}function L(e,t){let{alias:n}=F(e.to),r=t.find(e=>e.as===n);if(!r)throw Error(`Form field ${e.id} maps to unknown ${n}`);return r.model}function R(e,t){return e.default===void 0?t.default===void 0?t.type===`text`?``:null:t.default:e.default}function z(e,t){return Object.fromEntries(e.map(e=>[e.to,t[e.id]]))}var B=(e,t)=>e===t;async function V(e,t,n,r){let i={...n};for(let n of t){if(n.as in i)continue;if(!n.match){i[n.as]=void 0;continue}let t={},a=!0;for(let[e,r]of Object.entries(n.match))if(typeof r==`object`&&r){let n=i[r.ref];n||(a=!1),t[e]=r.field?n?.[r.field]:n?.id}else t[e]=r;i[n.as]=a?(await e.list(r(n.model))).find(e=>Object.entries(t).every(([t,n])=>B(e[t],n))):void 0}return i}var H=4,U=(e,t)=>e.fields.some(e=>e.name===t);function ie(e,n,i,a,c){let l=u(r(`${a}:${e.id}:${i.id}`)),f=U(e,`debit`)&&U(e,`credit`),p=f?2*(1+Math.floor(l()*2)):1+Math.floor(l()*H),m=o(e),h=1e3*(1+Math.floor(l()*90));return Array.from({length:p},(o,u)=>{let p=r(`${i.id}:${u}`)%997,g={...d(e,p,a,c),id:w(`${e.id}:${i.id}:${u}`),[n]:i.id};if(U(e,`sortOrder`)&&(g.sortOrder=u),m){let n=e.fields.find(e=>e.related?.endsWith(`:Product`)&&e.name in g),r=s(),{products:a}=r,o=n?a[t(n,{modelId:e.id,index:p,rows:c})%a.length]:a[p%a.length],d=b(p);d?(U(e,`description`)&&(g.description=d.description),g.unitPrice=d.price,n&&(g[n.name]=``)):n&&o&&(U(e,`description`)&&(g.description=o.name),g.unitPrice=o.price);let[f,m]=d?.quantity??o?.quantity??r.lineQuantity??[1,5],h=f+Math.floor(l()*(m-f+1));U(e,`quantity`)&&(g.quantity=h),Object.assign(g,q(e,i,u,h,Number(g.unitPrice??0))),g.amount=x(g)}if(f){let e=u%2==0;g.debit=e?h/100:0,g.credit=e?0:h/100}return g})}function W(e){return r(`discount:${e.id}`)%3==0}function G(e,t){return Math.round(e*t/1e3)*100}function K(e,t){return t>0&&r(`tax-override:${e.id}:${t}`)%7==0}function ae(t,n,i=c().currency){let a=r(`tax-override-kind:${t.id}:${n}`)%4,o=C(i);if(o&&a<2)return o;let s=a%2==0?`exempt`:`zero-rated`;return e.find(e=>e.kind===s)}function q(e,t,n,i,a){let o={},s=n===0&&W(t),c=r(`discount-kind:${t.id}`)%2==0;U(e,`discountType`)&&(o.discountType=s?c?`percent`:`amount`:`none`),U(e,`discountRate`)&&(o.discountRate=s&&c?`10`:null),U(e,`discount`)&&(o.discount=s&&!(c&&U(e,`discountType`))?G(i,a):0),!U(e,`discountType`)&&o.discount&&(o.discountType=`amount`);let l=K(t,n)?ae(t,n):void 0;return U(e,`taxMode`)&&(o.taxMode=l?`override`:`inherit`),U(e,`taxCodeId`)&&(o.taxCodeId=l?.id??null),o}function oe(e,t){let n={...e,...t};return`discount`in t&&!(`discountType`in t)&&n.discountType===`amount`&&(n.discountType=`percent`,n.discountRate=`10`,n.discount=0),`discountRate`in t&&n.discountType===`percent`&&(n.discountType=`none`,n.discountRate=null,n.discount=0),n}var se=[`@happyvertical/smrt-commerce:Order`,`@happyvertical/smrt-commerce:Invoice`],J=2500;function ce(e,t,n){n===2&&se.includes(t.id)&&typeof e.subtotal==`number`&&typeof e.totalAmount==`number`&&(t.fields.some(e=>e.name===`status`&&e.enum?.includes(`draft`))&&(e.status=`draft`),e.subtotal+=J,e.totalAmount+=J)}function le(e,t,n,r){if(!n.length||!n.every(e=>`unitPrice`in e))return[...n];let i=h(t,e,n,r);return Object.assign(e,i.row),i.lines}var Y=e=>typeof e==`number`&&Number.isFinite(e)?e:0,ue=e=>e.status!==`draft`&&e.status!==`cancelled`&&Y(e.totalAmount)>0;function de(e,t,n,i){let a=new Map(n.map(e=>[e.id,Y(e.totalAmount)])),o=[];for(let s of t){if(s.status!==`completed`){s.status!==`refunded`&&(s.paidAt=null);continue}let t=u(r(`${i}:alloc:${s.id}`)),c=n.filter(e=>ue(e)&&e.customerId===s.customerId&&(a.get(e.id)??0)>0).slice(0,t()<.3?2:1);if(c.length===0)continue;let l=c.map((e,n)=>{let r=a.get(e.id)??0,i=n>0||t()<.6?r:Math.min(r,Math.max(100,Math.round(r*(.3+t()*.4)/100)*100));return a.set(e.id,r-i),{inv:e,part:i}}),f=Math.max(...l.map(({inv:e})=>Date.parse(String(e.issueDate)))),p=new Date(Math.max(f,Math.min(f+(1+Math.floor(t()*20))*E,T))).toISOString();s.amount=l.reduce((e,t)=>e+t.part,0),s.paidAt=p,`contractId`in s&&l[0]?.inv.contractId&&(s.contractId=l[0].inv.contractId);for(let{inv:t,part:n}of l)o.push({...d(e.model,o.length,i),id:w(`${e.model.id}:${s.id}:${t.id}`),[e.paymentFk]:s.id,[e.invoiceFk]:t.id,amount:n,allocatedAt:p})}return o}function X(e){return typeof e==`object`&&!!e&&typeof e.ref==`string`}var Z=`smrt-planner:data:v6:`,fe=`@happyvertical/smrt-commerce:TaxCode`,Q=`@happyvertical/smrt-commerce:TaxComponent`,pe=[`taxable`,`zero-rated`,`exempt`,`out-of-scope`];function me(e,t){return!!e.fields.find(e=>e.name===`status`)?.enum?.includes(`draft`)&&typeof t.status==`string`&&t.status!==``&&t.status!==`draft`}var $=`${Z}_created`;function he(e){if(e)try{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(`smrt-planner:data:v6:`)&&t.push(r)}for(let n of t)e.removeItem(n)}catch{}}function ge(e={}){let t=e.seed??1,r=e.rowsPerModel??8,s=new Set(e.empty??[]),u=new Map,d=new Set,y=e.storage??null,b=e=>`${Z}${e.id}`,x=e=>{if(y)try{let t=y.getItem(b(e));if(t===null)return;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>typeof e==`object`&&!!e&&typeof e.id==`string`))return n}catch{}},C=0;if(y)try{C=Number(y.getItem($))||0}catch{C=0}let E=new Map,D=t=>{let n=E.get(t);return n||(n=e.children?.links(t)??[],E.set(t,n)),n},O,k,A=t=>{if(!O){O=new Map;for(let t of e.children?.models??[])for(let e of D(t.id)){let n=O.get(e.model.id)??[];n.push({parent:t,fk:e.fk}),O.set(e.model.id,n)}k=new Map(O);for(let[e,t]of O){let n=e.slice(e.lastIndexOf(`:`)+1).toLowerCase(),r=t.find(e=>n.startsWith(e.fk.replace(/Id$/,``).toLowerCase()))?.fk??t[0]?.fk;O.set(e,t.filter(e=>e.fk===r))}}return O.get(t)??[]},j=e=>{if(!a(e))return;A(e.id);let t=k?.get(e.id)??[],r=p(e)?.name,i=n(e)?.name,o=t.find(e=>e.fk===r)?.parent,s=t.find(e=>e.fk===i)?.parent;return o&&s&&r&&i?{model:e,paymentFk:r,invoiceFk:i,payment:o,invoice:s}:void 0},M=(t,n)=>{if(!_(t))return n;let r=D(t.id).find(e=>a(e.model)),i=r&&j(r.model);if(!r||!i)return n;let o=new Map(P(i.payment).map(e=>[e.id,e])),s=P(r.model).filter(e=>e[r.fk]===n.id&&o.get(String(e[i.paymentFk]))?.status===`completed`).map(e=>({amount:Number(e.amount??0),at:String(e.allocatedAt??``)})),c=g(n,s,(e.now??(()=>T))()),l={...n,amountPaid:c.amountPaid,status:c.status};return t.fields.some(e=>e.name===`paidDate`)&&(l.paidDate=c.paidDate),l},N=(e,t)=>{let n=P(e),r=n.findIndex(e=>e.id===t);r>=0&&(n[r]=M(e,n[r]))},P=n=>{let a=u.get(n.id);if(a)return a;let c=x(n);if(c){u.set(n.id,c);for(let e of D(n.id))P(e.model);return c}let l=s.has(n.id)?void 0:e.samples?.[n.id];if(l){let e=[];return u.set(n.id,e),e.push(...l.make(l.from.map(P),t)),e}let d=j(n),f=d?[]:A(n.id),p=s.has(n.id)||f.length||d?[]:i(n,ne(n.id,r),t,r);u.set(n.id,p);for(let e of D(n.id))P(e.model);if(d&&!s.has(n.id)){for(let e of D(d.invoice.id))o(e.model)&&P(e.model);let e=P(d.invoice);p.push(...de(d,P(d.payment),e,t)),e.forEach((t,n)=>{e[n]=M(d.invoice,t)})}if(!s.has(n.id))for(let{parent:i,fk:a}of f){let s=e.defaults?.(n)??{};P(i).forEach((e,c)=>{let l=ie(n,a,e,t,r).map(e=>oe(e,s));o(n)?(p.push(...le(e,i,l,L(i,e))),ce(e,i,c)):p.push(...l)})}return p},F=new Map((e.children?.models??[]).map(e=>[e.id,e])),I=e=>{let t=te(e),n=F.get(fe),r=F.get(Q),i=n?P(n):[];if(!i.length)return t;let a=new Map(t.flatMap(e=>e.components.map(e=>[e.id,e])));for(let e of r?P(r):[])a.set(e.id,{id:e.id,key:e.id,name:String(e.name??``),percent:String(e.percent??`0`),recoverable:e.recoverable===!0});let o=i.map(e=>{let t=[];try{t=JSON.parse(String(e.componentsJson??`[]`))}catch{t=[]}let n=(Array.isArray(t)?t:[]).flatMap(e=>{let t=e&&typeof e==`object`?a.get(String(e.taxComponentId)):void 0;return t?[t]:[]}),r=pe.includes(String(e.kind))?e.kind:`taxable`,i=[`sales`,`purchases`,`both`].includes(String(e.appliesTo))?e.appliesTo:`both`;return{id:e.id,code:String(e.code??``),name:String(e.name??``),kind:r,appliesTo:i,active:e.active!==!1,components:n}}),s=new Map(o.map(e=>[e.id,e]));if(t.some(e=>s.has(e.id))){let n=v(e);return[...t.filter(e=>s.has(e.id)||e.id===n.id).map(e=>s.get(e.id)??e),...o.filter(e=>!t.some(t=>t.id===e.id))]}return[...t,...o]},L=(e,t)=>{let n=c(),r=l()??.05,i=I(r),a=e.fields.find(e=>e.name===`customerId`&&e.related),o=a?.related?F.get(a.related):void 0,s=o?P(o).find(e=>e.id===t.customerId):void 0,d=e=>{for(let[t,n]of u){if(!t.endsWith(`:Product`))continue;let r=n.find(t=>t.id===e);if(r)return r}},p=e=>typeof e==`string`&&e?e:null;return{lineAmountType:f(t,n.pricesIncludeTax?`inclusive`:`exclusive`),roundingScope:m(t,n.taxRounding),currency:S(t.currency,S(n.currency)),codes:i,appDefaultCodeId:v(r).id,customerTaxExempt:s?.taxExempt===!0,partyCodeId:p(s?.defaultTaxCodeId),productCodeOf:e=>p(d(e)?.defaultSalesTaxCodeId)}},R=e=>{if(!y)return;let t=e=>{let t=j(e);return t?[t.payment,t.invoice]:[]},n=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent),...t(e),...D(e.id).flatMap(e=>t(e.model))];try{for(let e of n){let t=u.get(e.id);t&&y.setItem(b(e),JSON.stringify(t))}y.setItem($,String(C))}catch{}},z=e=>D(e.id).find(t=>o(t.model)&&A(t.model.id).some(n=>n.parent.id===e.id&&n.fk===t.fk)),B=(e,t,n=!1)=>{let r=z(e);if(!r)return!1;let i=P(e),a=i.findIndex(e=>e.id===t);if(a<0)return!1;let o=P(r.model),s=o.filter(e=>e[r.fk]===t),c=i[a];if(me(e,c)){if(n)throw new ee(`FROZEN_DOCUMENT`,`This ${e.name.toLowerCase()} has been issued, so its lines can no longer change.`);return!0}let l=h(e,c,s,L(e,c));i[a]=l.row;for(let e of l.lines){let t=o.findIndex(t=>t.id===e.id);t>=0&&(o[t]=e)}return!0},V=(e,t)=>{let n=t;if(z(e)&&(B(e,t.id),n=P(e).find(e=>e.id===t.id)??n),o(e)){let r=A(e.id).some(({parent:e,fk:n})=>B(e,t[n],!0)),i=P(e),a=i.findIndex(e=>e.id===t.id);if(!r&&a>=0){let e=c(),n=l()??.05;i[a]=re([t],{lineAmountType:e.pricesIncludeTax?`inclusive`:`exclusive`,roundingScope:e.taxRounding,currency:S(e.currency),codes:I(n),appDefaultCodeId:v(n).id}).lines[0]}n=P(e).find(e=>e.id===t.id)??n}_(e)&&(N(e,t.id),n=P(e).find(e=>e.id===t.id)??n);let r=j(e);r&&N(r.invoice,t[r.invoiceFk]);for(let n of D(e.id)){let r=j(n.model);if(r&&r.payment.id===e.id)for(let e of P(n.model))e[r.paymentFk]===t.id&&N(r.invoice,e[r.invoiceFk])}return n},H=e=>{let t=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent)];return new Map(t.map(e=>[e.id,P(e).map(e=>({...e}))]))},U=e=>{for(let[t,n]of e){let e=u.get(t);e&&e.splice(0,e.length,...n)}},W=(t,n)=>({...n,...e.defaults?.(t)??{}}),G=e=>w(`${e.id}:new:${t}:${C++}`),K=(e,t)=>Object.entries(t).every(([t,n])=>e[t]===n);return{async list(e){return P(e).map(t=>W(e,t))},async listWhere(e,t,n){return P(e).filter(e=>String(e[t]??``)===n).map(t=>W(e,t))},async get(e,t){let n=P(e).find(e=>e.id===t);return n?W(e,n):void 0},async create(t,n){let r={...e.defaults?.(t)??{},...n,id:G(t)},i=H(t);P(t).push(r);let a;try{a=V(t,r)}catch(e){throw U(i),C--,e}return R(t),{...a}},async update(e,t,n){let r=P(e),i=r.findIndex(e=>e.id===t);if(i<0)return;let a=H(e),s=r[i],c={...s,...n,id:t};r[i]=c;let l;try{if(l=V(e,c),o(e))for(let{parent:t,fk:n}of A(e.id))s[n]!==c[n]&&B(t,s[n],!0)}catch(e){throw U(a),e}return R(e),{...l}},async delete(e,t){let n=P(e),r=n.findIndex(e=>e.id===t);if(r<0)return!1;let i=H(e),[a]=n.splice(r,1);try{let t=j(e);t&&a&&N(t.invoice,a[t.invoiceFk]);for(let{parent:t,fk:n}of A(e.id))o(e)&&a&&B(t,a[n],!0)}catch(e){throw U(i),e}return R(e),!0},reset(){u.clear(),C=0,he(y);for(let e of[...d])e()},onReset(e){return d.add(e),()=>{d.delete(e)}},async apply(t){let n=new Map,r=C,i=new Map,a=e=>{i.set(e.id,e);let t=P(e);return n.has(e.id)||n.set(e.id,t.map(e=>({...e}))),t},o={},s=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!X(t))return[e,t];let n=o[t.ref];if(!n)throw Error(`Unknown record reference ${t.ref}`);return[e,t.field?n[t.field]:n.id]}));try{for(let n of t){let t=a(n.model),r=s(n.match);if(n.op===`delete`){let e=t.filter(e=>n.id===void 0?K(e,r):e.id===n.id);if(n.id===void 0&&Object.keys(r).length===0)throw Error(`A delete needs an id or a match`);for(let n of e)t.splice(t.indexOf(n),1);continue}let i=s(n.values),c=-1;if(n.id!==void 0){if(c=t.findIndex(e=>e.id===n.id),c<0)throw Error(`No ${n.model.name} with id ${n.id}`)}else Object.keys(r).length>0&&(c=t.findIndex(e=>K(e,r)));let l;if(c>=0){let e=t[c];l={...e,...i,id:e.id},t[c]=l}else l={...e.defaults?.(n.model)??{},...r,...s(n.onCreate),...i,id:G(n.model)},t.push(l);n.as&&(o[n.as]={...l})}}catch(e){for(let[e,t]of n)u.set(e,t);throw C=r,e}for(let e of i.values())R(e);return o}}}export{V as a,N as c,I as d,L as f,z as i,O as l,X as n,P as o,M as p,D as r,F as s,ge as t,R as u};
|
|
1
|
+
import{$ as e,A as t,B as n,D as r,E as i,G as a,K as o,M as s,N as c,P as l,S as u,T as d,U as f,V as p,W as m,X as h,Y as g,Z as _,ct as ee,et as v,ft as y,it as te,j as ne,k as b,nt as x,ot as re,rt as S,tt as C,w,x as T,y as E}from"./D3lXu_rt.js";var D=e=>{let t=y(e);if(!t)throw Error(`The catalog has no model ${e}`);return t.model};function O(e){return String(e??``).toUpperCase().replace(/[^A-Z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}var k=/\{([A-Za-z_][\w]*\.[A-Za-z_][\w]*)(?:\|(slug))?\}/g;function A(e,t){return e.replace(k,(e,n,r)=>{let i=t[n],a=i==null?``:String(i);return r===`slug`?O(a):a})}function j(e,t,n=e=>e){return typeof e==`string`?A(e,t):typeof e==`object`&&e?{ref:n(e.ref),...e.field?{field:e.field}:{}}:e}function M(e,t,n){return Object.fromEntries(Object.entries(e??{}).map(([e,r])=>[e,j(r,t,n)]))}function N(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`object`&&e&&!Array.isArray(e)?e:null}function P(e,t,n){return Object.fromEntries(e.flatMap(e=>{let r=F(e.to);return r.alias===t?[[r.field,N(n[e.id])]]:[]}))}function F(e){let t=e.indexOf(`.`);if(t<1||t===e.length-1)throw Error(`A form field maps to "alias.field", got "${e}"`);return{alias:e.slice(0,t),field:e.slice(t+1)}}function I(e,t,n){let{alias:r,field:i}=F(e.to),a=t.find(e=>e.as===r);if(!a)throw Error(`Form field ${e.id} maps to unknown ${r}`);let o=n(a.model).fields.find(e=>e.name===i);if(!o)throw Error(`${a.model} has no field ${i} (form field ${e.id})`);return o}function L(e,t){let{alias:n}=F(e.to),r=t.find(e=>e.as===n);if(!r)throw Error(`Form field ${e.id} maps to unknown ${n}`);return r.model}function R(e,t){return e.default===void 0?t.default===void 0?t.type===`text`?``:null:t.default:e.default}function z(e,t){return Object.fromEntries(e.map(e=>[e.to,t[e.id]]))}var B=(e,t)=>e===t;async function V(e,t,n,r){let i={...n};for(let n of t){if(n.as in i)continue;if(!n.match){i[n.as]=void 0;continue}let t={},a=!0;for(let[e,r]of Object.entries(n.match))if(typeof r==`object`&&r){let n=i[r.ref];n||(a=!1),t[e]=r.field?n?.[r.field]:n?.id}else t[e]=r;i[n.as]=a?(await e.list(r(n.model))).find(e=>Object.entries(t).every(([t,n])=>B(e[t],n))):void 0}return i}var H=4,U=(e,t)=>e.fields.some(e=>e.name===t);function ie(e,n,i,a,c){let l=u(r(`${a}:${e.id}:${i.id}`)),f=U(e,`debit`)&&U(e,`credit`),p=f?2*(1+Math.floor(l()*2)):1+Math.floor(l()*H),m=o(e),h=1e3*(1+Math.floor(l()*90));return Array.from({length:p},(o,u)=>{let p=r(`${i.id}:${u}`)%997,g={...d(e,p,a,c),id:w(`${e.id}:${i.id}:${u}`),[n]:i.id};if(U(e,`sortOrder`)&&(g.sortOrder=u),m){let n=e.fields.find(e=>e.related?.endsWith(`:Product`)&&e.name in g),r=s(),{products:a}=r,o=n?a[t(n,{modelId:e.id,index:p,rows:c})%a.length]:a[p%a.length],d=b(p);d?(U(e,`description`)&&(g.description=d.description),g.unitPrice=d.price,n&&(g[n.name]=``)):n&&o&&(U(e,`description`)&&(g.description=o.name),g.unitPrice=o.price);let[f,m]=d?.quantity??o?.quantity??r.lineQuantity??[1,5],h=f+Math.floor(l()*(m-f+1));U(e,`quantity`)&&(g.quantity=h),Object.assign(g,q(e,i,u,h,Number(g.unitPrice??0))),g.amount=x(g)}if(f){let e=u%2==0;g.debit=e?h/100:0,g.credit=e?0:h/100}return g})}function W(e){return r(`discount:${e.id}`)%3==0}function G(e,t){return Math.round(e*t/1e3)*100}function K(e,t){return t>0&&r(`tax-override:${e.id}:${t}`)%7==0}function ae(t,n,i=c().currency){let a=r(`tax-override-kind:${t.id}:${n}`)%4,o=C(i);if(o&&a<2)return o;let s=a%2==0?`exempt`:`zero-rated`;return e.find(e=>e.kind===s)}function q(e,t,n,i,a){let o={},s=n===0&&W(t),c=r(`discount-kind:${t.id}`)%2==0;U(e,`discountType`)&&(o.discountType=s?c?`percent`:`amount`:`none`),U(e,`discountRate`)&&(o.discountRate=s&&c?`10`:null),U(e,`discount`)&&(o.discount=s&&!(c&&U(e,`discountType`))?G(i,a):0),!U(e,`discountType`)&&o.discount&&(o.discountType=`amount`);let l=K(t,n)?ae(t,n):void 0;return U(e,`taxMode`)&&(o.taxMode=l?`override`:`inherit`),U(e,`taxCodeId`)&&(o.taxCodeId=l?.id??null),o}function oe(e,t){let n={...e,...t};return`discount`in t&&!(`discountType`in t)&&n.discountType===`amount`&&(n.discountType=`percent`,n.discountRate=`10`,n.discount=0),`discountRate`in t&&n.discountType===`percent`&&(n.discountType=`none`,n.discountRate=null,n.discount=0),n}var se=[`@happyvertical/smrt-commerce:Order`,`@happyvertical/smrt-commerce:Invoice`],J=2500;function ce(e,t,n){n===2&&se.includes(t.id)&&typeof e.subtotal==`number`&&typeof e.totalAmount==`number`&&(t.fields.some(e=>e.name===`status`&&e.enum?.includes(`draft`))&&(e.status=`draft`),e.subtotal+=J,e.totalAmount+=J)}function le(e,t,n,r){if(!n.length||!n.every(e=>`unitPrice`in e))return[...n];let i=h(t,e,n,r);return Object.assign(e,i.row),i.lines}var Y=e=>typeof e==`number`&&Number.isFinite(e)?e:0,ue=e=>e.status!==`draft`&&e.status!==`cancelled`&&Y(e.totalAmount)>0;function de(e,t,n,i){let a=new Map(n.map(e=>[e.id,Y(e.totalAmount)])),o=[];for(let s of t){if(s.status!==`completed`){s.status!==`refunded`&&(s.paidAt=null);continue}let t=u(r(`${i}:alloc:${s.id}`)),c=n.filter(e=>ue(e)&&e.customerId===s.customerId&&(a.get(e.id)??0)>0).slice(0,t()<.3?2:1);if(c.length===0)continue;let l=c.map((e,n)=>{let r=a.get(e.id)??0,i=n>0||t()<.6?r:Math.min(r,Math.max(100,Math.round(r*(.3+t()*.4)/100)*100));return a.set(e.id,r-i),{inv:e,part:i}}),f=Math.max(...l.map(({inv:e})=>Date.parse(String(e.issueDate)))),p=new Date(Math.max(f,Math.min(f+(1+Math.floor(t()*20))*E,T))).toISOString();s.amount=l.reduce((e,t)=>e+t.part,0),s.paidAt=p,`contractId`in s&&l[0]?.inv.contractId&&(s.contractId=l[0].inv.contractId);for(let{inv:t,part:n}of l)o.push({...d(e.model,o.length,i),id:w(`${e.model.id}:${s.id}:${t.id}`),[e.paymentFk]:s.id,[e.invoiceFk]:t.id,amount:n,allocatedAt:p})}return o}function X(e){return typeof e==`object`&&!!e&&typeof e.ref==`string`}var Z=`smrt-planner:data:v6:`,fe=`@happyvertical/smrt-commerce:TaxCode`,Q=`@happyvertical/smrt-commerce:TaxComponent`,pe=[`taxable`,`zero-rated`,`exempt`,`out-of-scope`];function me(e,t){return!!e.fields.find(e=>e.name===`status`)?.enum?.includes(`draft`)&&typeof t.status==`string`&&t.status!==``&&t.status!==`draft`}var $=`${Z}_created`;function he(e){if(e)try{let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r?.startsWith(`smrt-planner:data:v6:`)&&t.push(r)}for(let n of t)e.removeItem(n)}catch{}}function ge(e={}){let t=e.seed??1,r=e.rowsPerModel??8,s=new Set(e.empty??[]),u=new Map,d=new Set,y=e.storage??null,b=e=>`${Z}${e.id}`,x=e=>{if(y)try{let t=y.getItem(b(e));if(t===null)return;let n=JSON.parse(t);if(Array.isArray(n)&&n.every(e=>typeof e==`object`&&!!e&&typeof e.id==`string`))return n}catch{}},C=0;if(y)try{C=Number(y.getItem($))||0}catch{C=0}let E=new Map,D=t=>{let n=E.get(t);return n||(n=e.children?.links(t)??[],E.set(t,n)),n},O,k,A=t=>{if(!O){O=new Map;for(let t of e.children?.models??[])for(let e of D(t.id)){let n=O.get(e.model.id)??[];n.push({parent:t,fk:e.fk}),O.set(e.model.id,n)}k=new Map(O);for(let[e,t]of O){let n=e.slice(e.lastIndexOf(`:`)+1).toLowerCase(),r=t.find(e=>n.startsWith(e.fk.replace(/Id$/,``).toLowerCase()))?.fk??t[0]?.fk;O.set(e,t.filter(e=>e.fk===r))}}return O.get(t)??[]},j=e=>{if(!a(e))return;A(e.id);let t=k?.get(e.id)??[],r=p(e)?.name,i=n(e)?.name,o=t.find(e=>e.fk===r)?.parent,s=t.find(e=>e.fk===i)?.parent;return o&&s&&r&&i?{model:e,paymentFk:r,invoiceFk:i,payment:o,invoice:s}:void 0},M=(t,n)=>{if(!_(t))return n;let r=D(t.id).find(e=>a(e.model)),i=r&&j(r.model);if(!r||!i)return n;let o=new Map(P(i.payment).map(e=>[e.id,e])),s=P(r.model).filter(e=>e[r.fk]===n.id&&o.get(String(e[i.paymentFk]))?.status===`completed`).map(e=>({amount:Number(e.amount??0),at:String(e.allocatedAt??``)})),c=g(n,s,(e.now??(()=>T))()),l={...n,amountPaid:c.amountPaid,status:c.status};return t.fields.some(e=>e.name===`paidDate`)&&(l.paidDate=c.paidDate),l},N=(e,t)=>{let n=P(e),r=n.findIndex(e=>e.id===t);r>=0&&(n[r]=M(e,n[r]))},P=n=>{let a=u.get(n.id);if(a)return a;let c=x(n);if(c){u.set(n.id,c);for(let e of D(n.id))P(e.model);return c}let l=s.has(n.id)?void 0:e.samples?.[n.id];if(l){let e=[];return u.set(n.id,e),e.push(...l.make(l.from.map(P),t)),e}let d=j(n),f=d?[]:A(n.id),p=s.has(n.id)||f.length||d?[]:i(n,ne(n.id,r),t,r);u.set(n.id,p);for(let e of D(n.id))P(e.model);if(d&&!s.has(n.id)){for(let e of D(d.invoice.id))o(e.model)&&P(e.model);let e=P(d.invoice);p.push(...de(d,P(d.payment),e,t)),e.forEach((t,n)=>{e[n]=M(d.invoice,t)})}if(!s.has(n.id))for(let{parent:i,fk:a}of f){let s=e.defaults?.(n)??{};P(i).forEach((e,c)=>{let l=ie(n,a,e,t,r).map(e=>oe(e,s));o(n)?(p.push(...le(e,i,l,L(i,e))),ce(e,i,c)):p.push(...l)})}return p},F=new Map((e.children?.models??[]).map(e=>[e.id,e])),I=e=>{let t=te(e),n=F.get(fe),r=F.get(Q),i=n?P(n):[];if(!i.length)return t;let a=new Map(t.flatMap(e=>e.components.map(e=>[e.id,e])));for(let e of r?P(r):[])a.set(e.id,{id:e.id,key:e.id,name:String(e.name??``),percent:String(e.percent??`0`),recoverable:e.recoverable===!0});let o=i.map(e=>{let t=[];try{t=JSON.parse(String(e.componentsJson??`[]`))}catch{t=[]}let n=(Array.isArray(t)?t:[]).flatMap(e=>{let t=e&&typeof e==`object`?a.get(String(e.taxComponentId)):void 0;return t?[t]:[]}),r=pe.includes(String(e.kind))?e.kind:`taxable`,i=[`sales`,`purchases`,`both`].includes(String(e.appliesTo))?e.appliesTo:`both`;return{id:e.id,code:String(e.code??``),name:String(e.name??``),kind:r,appliesTo:i,active:e.active!==!1,components:n}}),s=new Map(o.map(e=>[e.id,e]));if(t.some(e=>s.has(e.id))){let n=v(e);return[...t.filter(e=>s.has(e.id)||e.id===n.id).map(e=>s.get(e.id)??e),...o.filter(e=>!t.some(t=>t.id===e.id))]}return[...t,...o]},L=(e,t)=>{let n=c(),r=l()??.05,i=I(r),a=e.fields.find(e=>e.name===`customerId`&&e.related),o=a?.related?F.get(a.related):void 0,s=o?P(o).find(e=>e.id===t.customerId):void 0,d=e=>{for(let[t,n]of u){if(!t.endsWith(`:Product`))continue;let r=n.find(t=>t.id===e);if(r)return r}},p=e=>typeof e==`string`&&e?e:null;return{lineAmountType:f(t,n.pricesIncludeTax?`inclusive`:`exclusive`),roundingScope:m(t,n.taxRounding),currency:S(t.currency,S(n.currency)),codes:i,appDefaultCodeId:v(r).id,customerTaxExempt:s?.taxExempt===!0,partyCodeId:p(s?.defaultTaxCodeId),productCodeOf:e=>p(d(e)?.defaultSalesTaxCodeId)}},R=e=>{if(!y)return;let t=e=>{let t=j(e);return t?[t.payment,t.invoice]:[]},n=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent),...t(e),...D(e.id).flatMap(e=>t(e.model))];try{for(let e of n){let t=u.get(e.id);t&&y.setItem(b(e),JSON.stringify(t))}y.setItem($,String(C))}catch{}},z=e=>D(e.id).find(t=>o(t.model)&&A(t.model.id).some(n=>n.parent.id===e.id&&n.fk===t.fk)),B=(e,t,n=!1)=>{let r=z(e);if(!r)return!1;let i=P(e),a=i.findIndex(e=>e.id===t);if(a<0)return!1;let o=P(r.model),s=o.filter(e=>e[r.fk]===t),c=i[a];if(me(e,c)){if(n)throw new ee(`FROZEN_DOCUMENT`,`This ${e.name.toLowerCase()} has been issued, so its lines can no longer change.`);return!0}let l=h(e,c,s,L(e,c));i[a]=l.row;for(let e of l.lines){let t=o.findIndex(t=>t.id===e.id);t>=0&&(o[t]=e)}return!0},V=(e,t)=>{let n=t;if(z(e)&&(B(e,t.id),n=P(e).find(e=>e.id===t.id)??n),o(e)){let r=A(e.id).some(({parent:e,fk:n})=>B(e,t[n],!0)),i=P(e),a=i.findIndex(e=>e.id===t.id);if(!r&&a>=0){let e=c(),n=l()??.05;i[a]=re([t],{lineAmountType:e.pricesIncludeTax?`inclusive`:`exclusive`,roundingScope:e.taxRounding,currency:S(e.currency),codes:I(n),appDefaultCodeId:v(n).id}).lines[0]}n=P(e).find(e=>e.id===t.id)??n}_(e)&&(N(e,t.id),n=P(e).find(e=>e.id===t.id)??n);let r=j(e);r&&N(r.invoice,t[r.invoiceFk]);for(let n of D(e.id)){let r=j(n.model);if(r&&r.payment.id===e.id)for(let e of P(n.model))e[r.paymentFk]===t.id&&N(r.invoice,e[r.invoiceFk])}return n},H=e=>{let t=[e,...D(e.id).map(e=>e.model),...A(e.id).map(e=>e.parent)];return new Map(t.map(e=>[e.id,P(e).map(e=>({...e}))]))},U=e=>{for(let[t,n]of e){let e=u.get(t);e&&e.splice(0,e.length,...n)}},W=(t,n)=>({...n,...e.defaults?.(t)??{}}),G=e=>w(`${e.id}:new:${t}:${C++}`),K=(e,t)=>Object.entries(t).every(([t,n])=>e[t]===n);return{async list(e){return P(e).map(t=>W(e,t))},async listWhere(e,t,n){return P(e).filter(e=>String(e[t]??``)===n).map(t=>W(e,t))},async get(e,t){let n=P(e).find(e=>e.id===t);return n?W(e,n):void 0},async create(t,n){let r={...e.defaults?.(t)??{},...n,id:G(t)},i=H(t);P(t).push(r);let a;try{a=V(t,r)}catch(e){throw U(i),C--,e}return R(t),{...a}},async update(e,t,n){let r=P(e),i=r.findIndex(e=>e.id===t);if(i<0)return;let a=H(e),s=r[i],c={...s,...n,id:t};r[i]=c;let l;try{if(l=V(e,c),o(e))for(let{parent:t,fk:n}of A(e.id))s[n]!==c[n]&&B(t,s[n],!0)}catch(e){throw U(a),e}return R(e),{...l}},async delete(e,t){let n=P(e),r=n.findIndex(e=>e.id===t);if(r<0)return!1;let i=H(e),[a]=n.splice(r,1);try{let t=j(e);t&&a&&N(t.invoice,a[t.invoiceFk]);for(let{parent:t,fk:n}of A(e.id))o(e)&&a&&B(t,a[n],!0)}catch(e){throw U(i),e}return R(e),!0},reset(){u.clear(),C=0,he(y);for(let e of[...d])e()},onReset(e){return d.add(e),()=>{d.delete(e)}},async apply(t){let n=new Map,r=C,i=new Map,a=e=>{i.set(e.id,e);let t=P(e);return n.has(e.id)||n.set(e.id,t.map(e=>({...e}))),t},o={},s=e=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!X(t))return[e,t];let n=o[t.ref];if(!n)throw Error(`Unknown record reference ${t.ref}`);return[e,t.field?n[t.field]:n.id]}));try{for(let n of t){let t=a(n.model),r=s(n.match);if(n.op===`delete`){let e=t.filter(e=>n.id===void 0?K(e,r):e.id===n.id);if(n.id===void 0&&Object.keys(r).length===0)throw Error(`A delete needs an id or a match`);for(let n of e)t.splice(t.indexOf(n),1);continue}let i=s(n.values),c=-1;if(n.id!==void 0){if(c=t.findIndex(e=>e.id===n.id),c<0)throw Error(`No ${n.model.name} with id ${n.id}`)}else Object.keys(r).length>0&&(c=t.findIndex(e=>K(e,r)));let l;if(c>=0){let e=t[c];l={...e,...i,id:e.id},t[c]=l}else l={...e.defaults?.(n.model)??{},...r,...s(n.onCreate),...i,id:G(n.model)},t.push(l);n.as&&(o[n.as]={...l})}}catch(e){for(let[e,t]of n)u.set(e,t);throw C=r,e}for(let e of i.values())R(e);return o}}}export{V as a,N as c,I as d,L as f,z as i,O as l,X as n,P as o,M as p,D as r,F as s,ge as t,R as u};
|