@wowok/agent-mcp 3.3.7 → 3.3.9
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/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/communication/message-cursors.d.ts +35 -0
- package/dist/communication/message-cursors.js +1 -0
- package/dist/communication/wts-attestation.d.ts +5 -0
- package/dist/communication/wts-attestation.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +2 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +7 -0
- package/dist/composition/inflight.js +1 -1
- package/dist/composition/materialize.d.ts +4 -1
- package/dist/composition/materialize.js +1 -1
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -1
- package/dist/config/store-policy.d.ts +14 -0
- package/dist/config/store-policy.js +1 -0
- package/dist/config/store-policy.spec.d.ts +1 -0
- package/dist/config/store-policy.spec.js +1 -0
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/user-preferences.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/business-modules.d.ts +1 -1
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.d.ts +1 -0
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/facts.spec.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/acquisition-flywheel.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +1 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.d.ts +6 -2
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +37 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +32 -2
- package/dist/knowledge/builtin-templates.d.ts +13 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/commission-landing.d.ts +26 -0
- package/dist/knowledge/commission-landing.js +1 -0
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +7 -0
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.d.ts +7 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.d.ts +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-fork-watch.d.ts +9 -0
- package/dist/knowledge/machine-fork-watch.js +1 -0
- package/dist/knowledge/migration-preflight.js +1 -1
- package/dist/knowledge/projection.spec.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +8 -2
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/semantic-ir.d.ts +24 -5
- package/dist/knowledge/semantic-ir.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-index.js +1 -1
- package/dist/knowledge/template-loader.d.ts +11 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +4 -2
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-validation.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.d.ts +12 -6
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +10 -2
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +1 -0
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +72 -1
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +3 -0
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/base.d.ts +24 -0
- package/dist/schema/call/bridge.d.ts +6 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +24 -0
- package/dist/schema/config/index.js +1 -1
- package/dist/schema/goal/index.d.ts +14 -0
- package/dist/schema/goal/planning.d.ts +26 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +9 -1
- package/dist/schema/industry-pack/modes.d.ts +9 -1
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/local/index.d.ts +60 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +278 -1
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +1 -0
- package/dist/schema/query/bi.d.ts +38 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +3 -0
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/service-clone/index.d.ts +17 -0
- package/dist/schema/service-clone/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +6 -0
- package/dist/schemas/benchmark_migration_operation.output.json +254 -2
- package/dist/schemas/benchmark_migration_operation.schema.json +87 -5
- package/dist/schemas/bridge_operation.output.json +6 -0
- package/dist/schemas/config_operation.output.json +95 -0
- package/dist/schemas/config_operation.schema.json +16 -1
- package/dist/schemas/goal_operation.schema.json +22 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +4 -0
- package/dist/schemas/industry_pack_operation.schema.json +40 -3
- package/dist/schemas/local_cache_operation.output.json +6 -0
- package/dist/schemas/local_history_operation.output.json +6 -0
- package/dist/schemas/local_info_operation.output.json +6 -0
- package/dist/schemas/local_mark_operation.output.json +6 -0
- package/dist/schemas/messenger_operation.output.json +609 -1
- package/dist/schemas/messenger_operation.schema.json +96 -1
- package/dist/schemas/onchain_operations.output.json +6 -0
- package/dist/schemas/onchain_operations.schema.json +334 -7
- package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
- package/dist/schemas/onchain_operations_guard.schema.json +318 -0
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +5 -5
- package/dist/schemas/query_toolkit.output.json +271 -8
- package/dist/schemas/service_clone_operation.output.json +79 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +14 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +19 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.d.ts +1 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/service-clone.d.ts +18 -0
- package/dist/tools/handlers/service-clone.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{resolve,dirname,join}from'path';import{getWowMcpDir,WowClient,getFullnodeUrl}from'@wowok/wowok';import{diagnose_passport_failure,verifyGuardFailureLegs,CallService,CallMachine,CallProgress,CallGuard,CallArbitration,CallRepository,CallContact,CallTreasury,CallReward,CallAllocation,CallPersonal,CallPayment,CallDemand,CallOrder,gen_passport,CallProof,gen_proof,ResponseData,LocalMark,query_objects,query_table,query_serviceContext,parseGuardFile,formatGuardParseErrors,transformRewardInput,transformPersonalInput,GetAccountOrMark_Address,Config,query_events,ObjectType,objectTypeFromAddress,isValidWowAddress}from'@wowok/wowok';import{buildOrderFundFacts}from'../../knowledge/arb-fund-facts.js';import{TASK_BINDING_SLOT}from'../../knowledge/onchain-constants.js';import{computeFundListingWall}from'../../graph/onchain/facts.js';import{renderGuardLegMap}from'../../knowledge/guard-leg-map.js';import{beginInFlight,recordInFlightOutcome,describeLastInFlight,inFlightParamsHash,lastInFlightMarker,matchOrderLandedEvent,pendingInFlightResend,attachInFlightDigest,parkUnknownOutcomeMarker,markerOpFor}from'../../composition/inflight.js';import{preflightPlan}from'../../composition/materialize.js';import{OnchainOperationsSchema,strictParse,getEnvConfig,handleCallResult,checkClientSchemaCompatibility,parseMachineNodesFromText,formatNodeErrors as a518a,machinePublishGateViolation,transformSubmission}from'../../schema/index.js';import{handlePermissionOperations}from'../../schema/call/permission-handler.js';import{resolveNetwork}from'./network.js';import{collectPermissionIndexes,checkPermissionAuthorization,formatPermissionWarning}from'../../schema/utils/permission-machine-check.js';import{getSkillsHintForOnchain}from'../../schema/utils/skills-recommendation.js';import{fetchEntityPermissions}from'../../playbooks/service-build/participation-radar.js';import{prepareFundOperation,parseAmount,generateSkillsHint as a518b,formatChainValue}from'../../knowledge/fund-layer.js';import{generateGuardSubmissionPrompt,formatSubmissionPrompt}from'../../knowledge/guard-submission-prompt.js';import{classifyRecipient,classifyDualPayoutTrack}from'../../knowledge/recipient-constraint.js';import{auditService}from'../../knowledge/audit-rules.js';import{translateGuardTypeError}from'../../knowledge/guard-lint.js';import{lintGuardNodeGates,parseGuardNodeGates,recordMachineNodeNames}from'../../knowledge/guard-node-gates.js';import{getGuardQueryByIdOrName}from'../../schema/utils/guard-query-utils.js';import{checkArbitrationVenueOrder,venueOperatingDoctrine}from'../../knowledge/arbitration-venue-order.js';import{assessAllocationRisks}from'../../knowledge/allocation-risk.js';import{ENTITY_RECIPIENT_RULE_ID,checkEntityRecipients,describeEntityRecipients,formatEntityRecipientViolation}from'../../knowledge/entity-recipient-guard.js';import{checkDiscountThresholdBeforeBuy,checkDiscountFloorBeforeIssue,describeBenchmarkIssueRisk}from'../../knowledge/discount-threshold.js';import{priorProofConsumptions,recordProofConsumption}from'../../communication/proof-reuse.js';import{evaluateServiceFromGraph}from'../../playbooks/service-build/topology-query.js';import{isEnabled as a518c}from'../../config/index.js';import{buildSubmissionConfirmation,diffGuardSpecVsChain,loadGuardJsonFromChain,OPERATION_GUARD_ACTION}from'../../knowledge/guard-submission-brief.js';import{enrichWorkflowGuidance,mergeGuidanceIntoOutput,resolveHoldableEdges,extractObjectVersionFromTx,extractProgressEventNodeFromTx}from'../../knowledge/workflow-guidance.js';import{runReviewChain,runReviewRepositoryWrite,runReviewRewardClaim,mergeReviewStepsIntoOutput}from'./review-chain.js';import{parseGuardTimeBounds,recordGuardTimeProfile,checkGuardAnchorReachability,formatGuardAnchorWarnings}from'../../knowledge/guard-anchor-reach.js';import{batchQueryObjectsByIds,batchReadAddressKeyedFields,fetchMachineNodes}from'../../graph/onchain/sdk-batch.js';import{normAddr,rootOf}from'../../graph/onchain/extract.js';import{classifyWipPath,probeWipReachability}from'../wip-deploy-assist.js';import{declareDispatchExpectation}from'./dispatch-expectations.js';import{stableOperationId}from'../../harness/operation-id.js';import{collectOnChainNamedObjectRequests,registerLocalMarksForCreatedObjects,planAutoLocalMark,operationPrimaryType,autoLocalMarkName}from'./onchain-name-registration.js';import{goalEngine}from'../../goal/GoalEngine.js';async function buildGuardSubmissionPrompt(a,b,c){if(!a||typeof a!=='object'||!('submission'in a))return undefined;const d=a['submission'];if(!Array['isArray'](d)||d['length']===0x0)return undefined;const f=d[0x0]?.['guard'];if(!f)return undefined;try{const g=await generateGuardSubmissionPrompt(f,{'operation':b,...c});return g?formatSubmissionPrompt(g):undefined;}catch(h){return'SUBMISSION\x20REQUIRED\x20—\x20the\x20Guard\x20needs\x20data\x20you\x20have\x20not\x20supplied\x20yet\x20(detailed\x20prompt\x20generation\x20'+('failed:\x20'+(h?.['message']??String(h))+').\x20Retry\x20with\x20the\x20submission\x20envelope\x20per\x20')+'SubmissionCallSchema:\x20{type:\x22submission\x22,\x20guard:[{object:\x22<guard\x20id>\x22,\x20impack:true}],\x20'+'submission:[{identifier:<n>,\x20value:\x22<value>\x22}]}\x20—\x20the\x20identifiers\x20above\x20name\x20every\x20required\x20field.';}}function treeUsesRewardRecords(a){if(!a||typeof a!=='object')return![];if(a['type']==='query_reward_record_exists')return!![];if(a['type']==='query'&&typeof a['query']==='string'&&/^reward\.record\.(exists_where|count_where|find_where|exists|count|find)$/['test'](a['query']))return!![];const b=[...Array['isArray'](a['nodes'])?a['nodes']:[],...Array['isArray'](a['and'])?a['and']:[],...Array['isArray'](a['or'])?a['or']:[],a['node'],a['left'],a['right']];return b['some'](d=>d&&typeof d==='object'&&treeUsesRewardRecords(d));}function treePinsRecordStamp(a){if(!a||typeof a!=='object')return![];const b=a['type']==='query_reward_record_exists'||a['type']==='query'&&typeof a['query']==='string'&&/^reward\.record\.(exists_where|count_where|find_where|exists|count|find)$/['test'](a['query']);if(b&&(a['where']?.['storeFromId']!=null||a['storeFromId']!=null))return!![];const c=[...Array['isArray'](a['nodes'])?a['nodes']:[],...Array['isArray'](a['and'])?a['and']:[],...Array['isArray'](a['or'])?a['or']:[],a['node'],a['left'],a['right']];return c['some'](d=>d&&typeof d==='object'&&treePinsRecordStamp(d));}export async function assertRewardReplayStamp(a,b,c=[]){if(!Array['isArray'](a))return;for(const d of a){if(!d||typeof d!=='object'||d['store_from_id']!=null)continue;let e,f;try{const h=await loadGuardJsonFromChain(String(d['guard']),b);h&&(e=treeUsesRewardRecords((h['json']??{})['root']),f=treePinsRecordStamp((h['json']??{})['root']));}catch{e=undefined;}if(e===!![]&&f===!![])throw new Error('reward.guard_add\x20REJECTED:\x20guard\x20\x27'+String(d['guard'])+'\x27\x20pins\x20a\x20storeFromId\x20predicate\x20'+'(order-scoped\x20record\x20query)\x20but\x20the\x20entry\x20omits\x20store_from_id\x20—\x20claim\x20records\x20are\x20written\x20'+'unstamped\x20and\x20match\x20NO\x20store_from\x20predicate,\x20so\x20the\x20per-order\x20leg\x20silently\x20never\x20fires\x20'+'(the\x20protocol\x20claim\x20key\x20still\x20bounds\x20each\x20recipient\x20to\x20one\x20claim,\x20but\x20the\x20once-per-order\x20'+'economics\x20the\x20tree\x20declares\x20are\x20dead).\x20Re-submit\x20with\x20store_from_id\x20=\x20the\x20table\x20identifier\x20'+'whose\x20submitted\x20value\x20identifies\x20the\x20claim\x20(slot\x200\x20—\x20the\x20submitted\x20Order\x20address\x20—\x20is\x20the\x20'+'conventional\x20once-per-order\x20stamp);\x20re-adding\x20the\x20SAME\x20guard\x20overwrites\x20its\x20slot\x20in\x20place.');if(e===!![]){c['push']('RECIPIENT-ONCE\x20REWARD\x20GUARD:\x20guard_add\x20for\x20\x27'+String(d['guard'])+'\x27\x20omits\x20store_from_id\x20and\x20its\x20record\x20'+'queries\x20pin\x20no\x20storeFromId\x20predicate\x20—\x20claims\x20are\x20bounded\x20by\x20the\x20protocol\x20claim\x20key\x20to\x20once\x20'+'per\x20recipient\x20for\x20life\x20(query\x20record-exists\x20is\x20recipient-scoped,\x20defaulting\x20to\x20the\x20signer;\x20the\x20'+'order.owner\x20identity\x20leg\x20is\x20what\x20decides\x20WHO\x20may\x20claim\x20—\x20keep\x20it).\x20If\x20once-per-ORDER\x20economics\x20'+'are\x20intended\x20instead,\x20re-add\x20with\x20store_from_id\x20pinned\x20(slot\x200\x20=\x20submitted\x20Order\x20address)\x20and\x20'+'an\x20order-scoped\x20where:{storeFromId:{identifier:<slot>}}\x20leg;\x20re-adding\x20the\x20SAME\x20guard\x20overwrites\x20'+'its\x20slot\x20in\x20place.\x20If\x20once-per-recipient\x20is\x20intended,\x20ignore\x20this\x20warning.');continue;}c['push']('REPLAY-OPEN\x20REWARD\x20GUARD:\x20guard_add\x20for\x20\x27'+String(d['guard'])+'\x27\x20omits\x20store_from_id\x20—\x20equality-based\x20per-order\x20dedup\x20can\x20never\x20'+'match\x20(records\x20without\x20the\x20pinned\x20value\x20match\x20NO\x20store_from_id\x20predicate;\x20slot-less\x20guards\x20can\x20only\x20dedup\x20'+'lifetime-once\x20via\x20record\x20count/exists\x20with\x20an\x20empty\x20where).\x20If\x20per-order\x20protection\x20is\x20intended,\x20re-add\x20'+'with\x20store_from_id\x20pinned\x20(slot\x200\x20=\x20submitted\x20Order\x20address\x20is\x20the\x20conventional\x20per-order\x20stamp;\x20re-adding\x20'+'the\x20SAME\x20guard\x20overwrites\x20its\x20slot\x20in\x20place,\x20so\x20existing\x20pools\x20can\x20be\x20repaired\x20without\x20a\x20new\x20guard);\x20'+'if\x20unlimited\x20repeat\x20claims\x20are\x20intended,\x20ignore\x20this\x20warning.');}}function assertRewardRecipientSemantics(a){if(!Array['isArray'](a))return;for(const b of a){if(!b||typeof b!=='object')continue;const c=b['recipient'];if(c!==null&&typeof c==='object'&&'GuardIdentifier'in c)throw new Error('reward.guard_add\x20REJECTED:\x20the\x20entry\x20for\x20guard\x20\x27'+String(b['guard'])+'\x27\x20'+'declares\x20recipient\x20{GuardIdentifier:\x20N}\x20—\x20the\x20claim\x20entry\x20requires\x20recipient\x20==\x20the\x20transaction\x20'+'sender\x20(reward\x20rail\x20abort\x2014,\x20E_CLAIM_RECIPIENT_NOT_SIGNER),\x20and\x20a\x20GuardIdentifier\x20resolves\x20from\x20'+'the\x20passport\x20submission\x20(conventionally\x20the\x20submitted\x20Order\x20address),\x20which\x20can\x20never\x20be\x20the\x20'+'signer:\x20the\x20entry\x20is\x20structurally\x20unpayable,\x20every\x20claim\x20aborts\x20(crs-mn-261015\x20F-12,\x20live\x20mainnet).\x20'+'Use\x20recipient\x20{Signer:\x20\x27signer\x27}\x20—\x20the\x20claim\x20guard\x27s\x20order.owner\x20identity\x20leg\x20keeps\x20it\x20buyer-bound\x20—\x20'+'or\x20an\x20{Entity}\x20recipient\x20(the\x20SDK\x20replaces\x20it\x20with\x20the\x20claimant\x27s\x20local\x20account\x20at\x20claim\x20time).\x20'+'The\x20GuardIdentifier\x20order-anchor\x20idiom\x20belongs\x20to\x20ALLOCATION\x20rails\x20only\x20(money\x20lands\x20ON\x20the\x20Order).');}}function chainForwardGuardRef(a){const b=a?.['guard'];return typeof b==='string'?b:typeof b?.['guard']==='string'?b['guard']:'';}async function fetchChainAnchorContext(a,b){try{if(typeof a!=='string'||a['trim']()==='')return undefined;let c=a['trim']();if(!c['startsWith']('0x')){const j=await LocalMark['Instance']()['get'](c);if(!j?.['address'])return undefined;c=j['address'];}const d=await query_table({'parent':c,'network':b?.['network']}),e=(d?.['items']??[])['map'](k=>k?.['object'])['filter'](k=>typeof k==='string'&&k['length']>0x0);if(e['length']===0x0)return undefined;const f=await query_objects({'objects':e,'network':b?.['network']}),g=(f?.['objects']??[])['filter'](k=>k?.['type']==='TableItem_MachineNode')['map'](k=>({'name':k['name'],'pairs':k['value']}));if(g['length']===0x0)return undefined;const h=new Set();for(const k of g){for(const l of k['pairs']??[]){for(const m of l?.['forwards']??[]){const o=chainForwardGuardRef(m);if(o)h['add'](o);}}}const i=new Map();for(const q of h){try{let r=q;if(!r['startsWith']('0x')){const v=await LocalMark['Instance']()['get'](r);if(!v?.['address'])continue;r=v['address'];}const s=await query_objects({'objects':[r],'network':b?.['network']}),t=s?.['objects']?.[0x0];if(!t||t['type']!=='Guard')continue;const u=parseGuardTimeBounds(t['root'],t['table']);if(!u)continue;i['set'](r['toLowerCase'](),u),i['set'](q['trim']()['toLowerCase'](),u);}catch{}}return{'nodes':g,'profiles':i};}catch{return undefined;}}async function maybeGuardSubmissionConfirmation(a,b){const d=[],e=a['submission'];if(e&&typeof e==='object'&&Array['isArray'](e['submission']))for(const l of e['submission']){l?.['guard']&&Array['isArray'](l['submission'])&&l['submission']['length']>0x0&&d['push']({'guardRef':String(l['guard']),'items':l['submission']});}const f=a['info'];if(f&&typeof f==='object'&&Array['isArray'](f['submission'])&&f['submission']['length']>0x0){const m=Array['isArray'](f['guard'])?f['guard']['map'](o=>o?.['object'])['filter'](Boolean):[],n=m[0x0]?String(m[0x0]):a['guard'];if(n)d['push']({'guardRef':String(n),'items':f['submission']});}if(d['length']===0x0)return undefined;const g=OPERATION_GUARD_ACTION[a['operation_type']],h=[];for(const o of d){const q=await buildSubmissionConfirmation({'guard_ref':o['guardRef'],'submission':o['items'],...g?{'action':g}:{},'network':b['network']});if(q)h['push'](q);}if(h['length']===0x0)return undefined;const i=h['map'](r=>r['confirmation_text'])['join']('\x0a\x0a'),j=[];for(const r of h){r['missing_identifiers']['length']>0x0&&j['push']('Guard\x20'+(r['guard_name']??r['guard'])+':\x20missing\x20required\x20identifier(s)\x20'+r['missing_identifiers']['join'](',\x20'));for(const s of r['items']){for(const t of s['issues']){j['push']('Guard\x20'+(r['guard_name']??r['guard'])+'\x20['+(s['identifier']??'?')+']:\x20'+t);}}}const k={'message':i,'result':{'type':'pending_confirmation','preview':{'level':'standard','operation':a['operation_type'],'object':h[0x0]['guard_name']??h[0x0]['guard'],'network':b['network'],...j['length']>0x0?{'warnings':j}:{}},'rule_id':'guard_submission_confirm'},'semantic':{'intent':a['operation_type']+'_guard_submission_awaiting_confirmation','status':'pending_input','summary':'Guard\x20submission\x20composed-confirmation\x20(G1):\x20the\x20complete\x20semantics\x20of\x20your\x20submission\x20'+'(guard\x20rules\x20+\x20your\x20values\x20+\x20pass/fail\x20consequences)\x20are\x20shown\x20in\x20the\x20message.\x20'+'The\x20operation\x20was\x20NOT\x20executed.\x20Re-call\x20with\x20env.confirmed=true\x20to\x20proceed.','next_actions':[{'action':'confirm:\x20re-call\x20the\x20SAME\x20operation\x20with\x20env.confirmed=true','reason':'Guard\x20submission\x20confirmation\x20—\x20'+h['length']+'\x20guard(s),\x20'+d['reduce']((u,v)=>u+v['items']['length'],0x0)+'\x20submitted\x20item(s).','tool':'onchain_operations','priority':'required'}],...j['length']>0x0?{'warnings':j}:{}}};return{'content':[{'type':'text','text':i}],'structuredContent':k};}const REFERRER_FILE=join(getWowMcpDir(),'referrer');function readStoredReferrer(){try{if(!existsSync(REFERRER_FILE))return null;const a=readFileSync(REFERRER_FILE,'utf8')['trim']();return a||null;}catch{return null;}}const PROJECT_SKILL_DIRS=['.claude/skills','.agents/skills','.cursor/rules','.github/prompts','.windsurf/skills','.codex/skills','.qoder/skills','.roo/skills','.codebuddy/skills'],PROJECT_SKILL_MARKERS=['wowok-provider','wowok-supplier','wowok-collaborator','wowok-arbitrator','wowok-order','wowok-messenger','wowok-machine','wowok-output','wowok-onboard','wowok-planner','wowok-auditor','wowok-governance'],SKILLS_HINT_FILE=join(getWowMcpDir(),'skills-hint-asked.json');function projectHasSkills(a){for(const b of PROJECT_SKILL_DIRS){for(const c of PROJECT_SKILL_MARKERS){if(existsSync(join(a,b,c)))return!![];}}return![];}function loadSkillsAsked(){try{if(!existsSync(SKILLS_HINT_FILE))return{};return JSON['parse'](readFileSync(SKILLS_HINT_FILE,'utf8'))??{};}catch{return{};}}function persistSkillsAsked(a){try{const b=loadSkillsAsked();b[a]=!![],mkdirSync(dirname(SKILLS_HINT_FILE),{'recursive':!![]}),writeFileSync(SKILLS_HINT_FILE,JSON['stringify'](b,null,0x2),'utf8');}catch{}}function getProjectSkillsHint(){try{const a=process['cwd']();if(!a||projectHasSkills(a))return null;const b=loadSkillsAsked();if(b[a])return null;return persistSkillsAsked(a),'WoWok\x20skills\x20are\x20not\x20installed\x20in\x20this\x20project.\x20Run\x20`wowok-skills\x20init`\x20'+'here\x20to\x20install\x20them\x20(the\x20MCP\x20works\x20regardless;\x20skills\x20improve\x20AI\x20orchestration).';}catch{return null;}}function formatRecipientLabel(a){if(!a)return'unknown';if(typeof a==='string')return a;const b=classifyRecipient(a);if(!b)return JSON['stringify'](a);if(b['kind']==='submission')return'submitted\x20object\x20slot\x20'+b['identifier']+'\x20(object\x20receipt\x20=\x20owner\x20receipt)';if(b['kind']==='signer')return'Signer\x20(caller\x20of\x20the\x20guard-gated\x20alloc)';const c=b['address'];if(c['length']>0x10)return'Entity('+c['slice'](0x0,0x8)+'...'+c['slice'](-0x4)+')';return'Entity('+c+')';}function formatMistAmount(a){const b=Number(a)/0x3b9aca00;if(b===0x0)return'0\x20WOW';const c=b['toFixed'](0x9)['replace'](/\.?0+$/,'');return c+'\x20WOW\x20('+a['toString']()+'\x20MIST)';}function extractNodesForCheck(a){if(!a?.['node'])return[];if(a['node']['nodes']&&Array['isArray'](a['node']['nodes']))return a['node']['nodes'];return[];}function resolvePermissionRef(a){if(!a?.['object'])return null;if(typeof a['object']==='string')return null;const b=a['object'];if(b['permission']){if(typeof b['permission']==='string')return b['permission'];return null;}return null;}function warnPermissionAutoCreation(a,b,c){const d=a?.['object'];d!==null&&typeof d==='object'&&d['permission']===undefined&&c['push']('PERMISSION\x20AUTO-CREATION:\x20no\x20\x27permission\x27\x20specified\x20in\x20the\x20'+b+'\x20creation\x20payload\x20—\x20a\x20NEW\x20Permission\x20object\x20is\x20created\x20automatically.\x20'+'To\x20reuse\x20an\x20existing\x20Permission\x20(recommended\x20when\x20one\x20owner\x20governs\x20several\x20objects),\x20set\x20object.permission\x20to\x20its\x20address\x20or\x20LocalMark\x20name.');}export async function warnMerchantCompensationFundLow(a,b,c){const d=a?.['object'];if(typeof d!=='string'||!d['trim']())return;let e;try{const r=await query_objects({'objects':[d],'network':b,'no_cache':!![]});e=r?.['objects']?.[0x0];}catch{return;}if(!e||e['type']!=='Service')return;const f=s=>{if(typeof s==='number'&&Number['isFinite'](s)&&s>=0x0)return BigInt(Math['trunc'](s));if(typeof s==='string'&&/^\d+$/['test'](s['trim']()))return BigInt(s['trim']());return undefined;},g=(String(e['type']??e['type_raw']??'')['match'](/<(.+)>$/)??[])[0x1]??'',h=Array['isArray'](e['sales'])?e['sales']:[],i=h['map'](t=>f(t?.['price']))['filter'](s=>s!==undefined),j=f(e['compensation_fund']);if(j===undefined||i['length']===0x0)return;const k=i['reduce']((s,t)=>t>s?t:s);let l=j;const m=a?.['compensation_fund_add']?.['balance'];if(m!=null){const s=f(m);if(s!==undefined)l=j+s;else{if(!g)return;try{const t=await parseAmount(String(m),g,b);l=j+t['smallestUnit'];}catch{return;}}}const n=a?.['compensation_fund_withdraw']!=null;if(n)l=0x0n;const o=0x3n;if(l>=o*k)return undefined;const p=async u=>{try{return g?(await formatChainValue(u,g,b))['display']:u['toString']();}catch{return u['toString']();}},q='Service\x20\x27'+d+'\x27\x20compensation_fund\x20holds\x20'+await p(l)+'\x20(raw\x20'+l+')\x20—\x20below\x20the\x20'+('award\x20ceiling\x20of\x20'+o+'x\x20the\x20highest\x20SKU\x20price\x20=\x20')+(await p(o*k)+'\x20(raw\x20'+o*k+';\x20the\x20highest\x20')+('SKU\x20price\x20itself\x20is\x20'+await p(k)+').\x20A\x20valid\x20')+'arbitration\x20award\x20above\x20the\x20current\x20balance\x20aborts\x20the\x20buyer\x27s\x20payout\x20with\x20code\x2027\x20'+'(E_COMPENSATION_NOT_MATCH);\x20the\x20abort\x20does\x20NOT\x20consume\x20the\x20claim,\x20and\x20the\x20pool\x20is\x20NEVER\x20auto-refilled.';if(a?.['publish']===!![])return c['push']('MERCHANT\x20FUND\x20DISCLOSURE\x20(publish\x20proceeding\x20—\x20per-order\x20coverage\x20is\x20enforced\x20at\x20BUY\x20time):\x20'+q+'\x20'+'Each\x20incoming\x20order\x20will\x20be\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount,\x20not\x203x\x20the\x20highest\x20SKU.\x20Top\x20up\x20via\x20'+'service.compensation_fund_add\x20to\x20widen\x20the\x20payout\x20pool\x20—\x20until\x20then\x20awards\x20beyond\x20the\x20fund\x20abort\x20'+'the\x20buyer\x27s\x20claim\x20with\x20code\x2027\x20(the\x20abort\x20does\x20NOT\x20consume\x20the\x20claim)\x20and\x20the\x20merchant\x20wallet\x20'+'is\x20the\x20backstop.'),undefined;return c['push']('MERCHANT\x20FUND\x20REMINDER\x20(operational):\x20'+q+'\x20Top\x20up\x20via\x20'+'service.compensation_fund_add\x20—\x20each\x20incoming\x20order\x20is\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount\x20at\x20buy\x20time,\x20'+'so\x20size\x20the\x20fund\x20for\x20your\x20typical\x20single\x20order\x20(3x\x20covers\x20any\x20single\x20ruling;\x20more\x20only\x20buys\x20headroom\x20'+'for\x20several\x20concurrent\x20claims).'+(n?'\x20NOTE:\x20this\x20call\x20withdraws\x20the\x20fund\x20—\x20buyers\x20lose\x20payout\x20protection\x20entirely.':'')),undefined;}async function resolveStringRef(a){if(typeof a!=='string')return undefined;const b=a['trim']();if(!b)return undefined;if(/^0x[0-9a-fA-F]{1,64}$/['test'](b))return b['toLowerCase']();try{return await GetAccountOrMark_Address(b)??undefined;}catch{return undefined;}}const ADDR_RE=/^0x[0-9a-fA-F]{1,64}$/;async function assertReferencesResolve(a,b){const c=a?.['data'];if(!c||typeof c!=='object')return;const d=b?.['network']?'\x20(network:\x20'+b['network']+')':'';if(typeof c['object']==='string'&&c['object']['trim']()&&!ADDR_RE['test'](c['object']['trim']())){const g=await resolveStringRef(c['object']);if(!g)throw new Error('invalid\x20parameter:object\x20\x27'+c['object']+'\x27\x20not\x20found\x20locally'+d+'\x20—\x20check\x20local_mark_list\x20/\x20account_list,\x20or\x20pass\x20the\x20on-chain\x20object\x20ID');}const e=typeof c['object']==='object'&&c['object']!==null?c['object']:undefined,f=e?.['permission'];if(typeof f==='string'&&f['trim']()&&!ADDR_RE['test'](f['trim']())){const h=await resolveStringRef(f);if(!h)throw new Error('invalid\x20parameter:permission\x20\x27'+f+'\x27\x20not\x20found\x20locally'+d+'\x20—\x20pass\x20the\x20Permission\x27s\x20object\x20ID,\x20register\x20the\x20mark\x20first,\x20or\x20use\x20the\x20object\x20form\x20permission:{name:\x22'+f+'\x22}\x20to\x20CREATE\x20a\x20new\x20Permission');}}async function checkMachinePermissionBeforePublish(a,b){if(a?.['publish']!==!![])return'';const c=extractNodesForCheck(a);if(c['length']===0x0)return'';const d=collectPermissionIndexes(c);if(d['requiredIndexes']['length']===0x0)return'';let e='';if(d['missingRefs']['length']>0x0){e+='WARNING:\x20Some\x20forwards\x20have\x20NEITHER\x20permissionIndex\x20nor\x20namedOperator.\x20'+'These\x20forwards\x20cannot\x20be\x20executed.\x20Add\x20one\x20or\x20the\x20other:\x0a';for(const k of d['missingRefs']){e+='\x20\x20-\x20Node\x20\x22'+k['nodeName']+'\x22,\x20pair\x20prev_node=\x22'+k['prevNode']+'\x22,\x20forward\x20\x22'+k['forwardName']+'\x22\x0a';}e+='\x0a';}const f=resolvePermissionRef(a);if(!f)return d['requiredIndexes']['length']>0x0&&(e+='PRE-PUBLISH\x20REMINDER:\x20This\x20Machine\x20uses\x20'+d['requiredIndexes']['length']+'\x20custom\x20permission\x20index(es):\x20['+d['requiredIndexes']['join'](',\x20')+'].\x20'+'After\x20creating\x20the\x20Permission\x20object,\x20grant\x20entities\x20for\x20each\x20index\x20via\x20'+'permission.op=\x22add\x20perm\x20by\x20index\x22\x20BEFORE\x20publishing\x20the\x20Machine.\x20'+'Otherwise,\x20forwards\x20using\x20these\x20indexes\x20will\x20be\x20un-executable.\x0a'),e;let g=f;if(!f['startsWith']('0x'))try{const l=await LocalMark['Instance']()['get'](f);if(l?.['address'])g=l['address'];else return e+'PRE-PUBLISH:\x20Could\x20not\x20resolve\x20Permission\x20name\x20\x27'+f+'\x27\x20to\x20an\x20address.\x20Ensure\x20the\x20Permission\x20object\x20exists\x20and\x20is\x20marked.\x20'+'Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}catch{return e+'PRE-PUBLISH:\x20Failed\x20to\x20lookup\x20Permission\x20name\x20\x27'+f+'\x27.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}const h=await resolveNetwork(b?.['network']);let i=null;try{const m=await query_objects({'objects':[g],'network':h}),n=m?.['objects']?.[0x0];if(n){i={'address':g,'entity_count':n['entity_count'],'perm_remark':n['perm_remark'],'owner':n['owner']??n['builder'],'admin':n['admin']};try{i['entityPermissions']=await fetchEntityPermissions(g,h);}catch{}}}catch{return e+'PRE-PUBLISH:\x20Failed\x20to\x20query\x20Permission\x20object\x20'+g+'.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}if(!i)return e+'PRE-PUBLISH:\x20Permission\x20object\x20'+g+'\x20not\x20found\x20on-chain.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';const j=checkPermissionAuthorization(d['requiredIndexes'],i);return(!j['allAuthorized']||!j['allVerified'])&&(e+=formatPermissionWarning(j)+'\x0a'),e;}async function detectServiceGuardCircularDependency(a){if(!a||typeof a['object']!=='object'||a['object']===null)return null;const b=a['order_allocators'];if(!b||typeof b!=='object')return null;const c=Array['isArray'](b['allocators'])?b['allocators']:[];if(c['length']===0x0)return null;const d=[],e=new Set();for(const k of c){const l=k?.['guard'];if(typeof l==='string'&&!l['startsWith']('0x')){if(e['has'](l))continue;e['add'](l);try{const m=await LocalMark['Instance']()['get_address'](l);!m&&d['push'](l);}catch{d['push'](l);}}}if(d['length']===0x0)return null;const f=d['map'](n=>'\x27'+n+'\x27')['join'](',\x20'),g=a['object'],h=g['name']??'<service_name>',i=[{'step':0x1,'action':'onchain_operations','operation_type':'service','params':{...a,'order_allocators':null,'publish':![]},'purpose':'Create\x20Service\x20\x27'+h+'\x27\x20WITHOUT\x20order_allocators\x20to\x20establish\x20'+('its\x20LocalMark\x20entry.\x20After\x20this\x20step,\x20the\x20name\x20\x27'+h+'\x27\x20resolves\x20')+'to\x20an\x20on-chain\x20address.'},{'step':0x2,'action':'onchain_operations','operation_type':'guard','params':d['map'](n=>({'object':{'name':n,'type':'Guard'},'_hint':'Table\x20items\x20may\x20reference\x20Service\x20\x27'+h+'\x27\x20by\x20name'})),'purpose':'Create\x20Guard(s)\x20'+f+'.\x20Their\x20table\x20items\x20can\x20now\x20resolve\x20'+('Service\x20\x27'+h+'\x27\x20by\x20name\x20(LocalMark\x20entry\x20from\x20step\x201).')},{'step':0x3,'action':'onchain_operations','operation_type':'service','params':{'object':h,'order_allocators':b,'publish':a['publish']??!![]},'purpose':'Update\x20Service\x20with\x20order_allocators\x20(referencing\x20Guards\x20created\x20in\x20'+'step\x202)\x20and\x20publish.\x20After\x20publish,\x20order_allocators\x20becomes\x20SDK-LOCKED.'}],j='⚠️\x20Circular\x20dependency\x20detected:\x20Service\x20↔\x20Guard\x0a\x0a'+('Cannot\x20create\x20Service\x20with\x20order_allocators\x20referencing\x20non-existent\x20Guard(s):\x20'+f+'.\x0a\x0a')+'Explanation:\x20Guard\x20table\x20items\x20may\x20reference\x20the\x20Service\x20by\x20name,\x20creating\x20a\x20circular\x20'+'dependency:\x20the\x20Service\x20must\x20exist\x20as\x20a\x20LocalMark\x20before\x20the\x20Guard\x20can\x20resolve\x20it,\x20'+'but\x20the\x20Guard\x20must\x20exist\x20before\x20the\x20Service\x20can\x20reference\x20it\x20in\x20order_allocators.\x20'+'The\x20SDK\x20would\x20fail\x20with\x20a\x20BCS\x20serialization\x20error:\x20\x22Expected\x20valid\x20Address\x20for\x20'+'ValueType.Address,\x20but\x20failed\x20to\x20resolve\x20string:\x20<name>\x22.\x0a\x0a'+'Recommended\x20steps:\x0a'+i['map'](n=>'\x20\x20Step\x20'+n['step']+'\x20('+n['operation_type']+'):\x20'+n['purpose'])['join']('\x0a')+'\x0a\x0aHint:\x20This\x20is\x20the\x20canonical\x20Service↔Guard\x20circular\x20dependency.\x20The\x203-step\x20'+'pattern\x20above\x20is\x20the\x20documented\x20solution\x20(see\x20SCHEMA-03\x20/\x20P0-01\x20fix\x20in\x20'+'schema/call/service.ts\x20publish\x20field\x20description).';return{'content':[{'type':'text','text':j}],'structuredContent':{'result':{'type':'error','error':'Cannot\x20create\x20Service\x20with\x20order_allocators\x20referencing\x20non-existent\x20Guard(s):\x20'+f+'.\x20Circular\x20dependency:\x20Service↔Guard.','error_code':'circular_dependency_detected','retryable':!![],'recovery_hint':JSON['stringify'](i),'related_object':h},'message':'Circular\x20dependency\x20detected:\x20Service\x20↔\x20Guard.\x20See\x20recovery_hint\x20for\x20the\x203-step\x20creation\x20pattern.'}};}function buildFundBlockResult(a,b){const c=a['matchErrors']['length']>0x0,d=a['errors']['length']>0x0,e=a['blockingErrors']['some'](k=>k['includes']('TOKEN\x20CHOICE\x20REQUIRED')),f=c&&d?'FUND\x20OPERATION\x20BLOCKED':c?'TOKEN\x20TYPE\x20MISMATCH\x20—\x20operation\x20blocked':e?'TOKEN\x20CHOICE\x20REQUIRED\x20—\x20operation\x20blocked,\x20awaiting\x20user\x20selection':'FUND\x20INPUT\x20BLOCKED\x20—\x20operation\x20blocked',g=c&&d?'fund_blocked':c?'token_type_mismatch':e?'token_choice_required':'fund_input_error',h=c?'\x0a\x0aThe\x20token\x20type\x20of\x20a\x20generic\x20on-chain\x20object\x20(e.g.\x20Treasury<T>,\x20Service<T>)\x20is\x20'+'determined\x20at\x20creation\x20and\x20can\x20NEVER\x20be\x20changed,\x20and\x20monetary\x20input\x20is\x20never\x20'+('processed\x20with\x20unknown\x20token\x20precision.\x20This\x20'+b+'\x20operation\x20was\x20')+'NOT\x20executed.\x20Fix\x20the\x20errors\x20above\x20and\x20re-issue\x20the\x20operation'+(a['objectTokenType']?'\x20(object\x20token\x20type:\x20'+a['objectTokenType']+')':'')+'.':e?'\x0a\x0aMultiple\x20on-chain\x20tokens\x20may\x20legally\x20share\x20the\x20same\x20symbol\x20(several\x20'+'issuers\x20can\x20each\x20publish\x20a\x20\x22USDT\x22),\x20so\x20a\x20bare\x20symbol\x20can\x20never\x20identify\x20'+('the\x20issuer.\x20This\x20'+b+'\x20operation\x20was\x20NOT\x20executed\x20and\x20no\x20')+'on-chain\x20action\x20was\x20taken.\x20Present\x20the\x20numbered\x20candidate\x20list\x20above\x20to\x20'+'the\x20USER,\x20wait\x20for\x20their\x20choice,\x20then\x20re-issue\x20with\x20the\x20chosen\x20token\x27s\x20'+'full\x20type.':'\x0a\x0aMonetary\x20input\x20is\x20never\x20processed\x20with\x20unknown\x20token\x20precision\x20or\x20an\x20'+('unparseable\x20amount.\x20This\x20'+b+'\x20operation\x20was\x20NOT\x20executed\x20and\x20')+'no\x20on-chain\x20action\x20was\x20taken.\x20Follow\x20the\x20recovery\x20steps\x20in\x20the\x20error\x20'+'above\x20and\x20re-issue\x20the\x20operation.',i='⛔\x20'+f+'\x0a\x0a'+a['blockingErrors']['map'](k=>'\x20\x20•\x20'+k)['join']('\x0a')+h,j=e?'Present\x20the\x20numbered\x20token\x20candidate\x20list\x20from\x20the\x20error\x20message\x20to\x20the\x20USER\x20'+'(full\x20type,\x20name,\x20decimals,\x20verified\x20tag\x20are\x20all\x20shown)\x20—\x20do\x20NOT\x20pick\x20an\x20'+'issuer\x20yourself.\x20After\x20the\x20user\x20chooses\x20(by\x20number\x20or\x20by\x20pasting\x20the\x20full\x20'+('type),\x20re-issue\x20this\x20'+b+'\x20operation\x20with\x20that\x20token\x27s\x20FULL\x20type\x20')+'string\x20(package::module::Name)\x20in\x20type_parameter\x20(object.type_parameter\x20for\x20'+'service\x20creation;\x20root\x20type_parameter\x20for\x20payment\x20receive).\x20Also\x20verify\x20the\x20'+'WOW\x20network\x20selection\x20is\x20correct.':'Use\x20token\x20type\x20'+(a['objectTokenType']??'<the\x20object\x27s\x20generic\x20token\x20type>')+'\x20for\x20all\x20'+('amounts,\x20coins,\x20and\x20receive\x20records\x20in\x20this\x20'+b+'\x20operation.\x20')+'Query\x20the\x20object\x20via\x20query_toolkit\x20onchain_objects\x20to\x20confirm\x20its\x20generic\x20'+'token\x20type\x20(type_raw,\x20e.g.\x20\x220x2::treasury::Treasury<0x2::wow::WOW>\x22).\x20'+'For\x20precision-unavailable\x20tokens,\x20retry\x20the\x20operation\x20—\x20the\x20on-chain\x20'+'metadata\x20lookup\x20may\x20have\x20been\x20transient.';return{'content':[{'type':'text','text':i}],'structuredContent':{'result':{'type':'error','error':a['blockingErrors']['join']('\x20|\x20'),'error_code':g,'retryable':!![],'recovery_hint':j},'message':'Fund\x20operation\x20blocked\x20before\x20execution.'}};}async function checkSalesWipNetworkDeployment(a,b,c){const d=a?.['sales'];if(!d||typeof d!=='object')return null;if(d['op']!=='add'&&d['op']!=='set')return null;const e=Array['isArray'](d['sales'])?d['sales']:[];if(e['length']===0x0)return null;const f=b?.['network']==='localnet';for(const g of e){const h=g?.['wip'];if(typeof h!=='string'||h==='')continue;const i=classifyWipPath(h),j=!i['is_local']&&i['is_network']&&!f&&(i['type']==='http_url'||i['type']==='ipfs'&&/^https?:/i['test'](h));if(j){const m=await probeWipReachability(h)['catch'](()=>({'ok':![],'reason':'probe\x20failed'}));if(!m['ok']){const n=m['status']?'HTTP\x20'+m['status']:m['reason']??'unreachable',o='⛔\x20WIP\x20HOST\x20UNREACHABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20but\x20the\x20host\x20is\x20not\x20reachable\x20('+n+').\x0a\x0a')+'Every\x20customer\x20order_new\x20fetches\x20this\x20URL\x20to\x20verify\x20the\x20WIP\x20file\x20—\x20while\x20it\x20is\x20'+'down,\x20ALL\x20purchases\x20on\x20this\x20Service\x20abort\x20100%\x20(F-27:\x20WIP\x20single-host\x20outage\x20'+'famously\x20took\x20every\x20listing\x20down\x20at\x20once).\x0a\x0a'+'This\x20is\x20NOT\x20a\x20wrong-network\x20problem\x20—\x20do\x20NOT\x20switch\x20networks.\x0a\x0a'+'Fix:\x0a'+'\x20\x20•\x20Transient\x20outage:\x20wait\x20for\x20the\x20host\x20to\x20recover,\x20then\x20re-run\x20this\x20operation.\x0a'+'\x20\x20•\x20Permanent:\x20redeploy\x20the\x20.wip\x20file\x20to\x20another\x20public\x20endpoint\x20and\x20update\x20'+'sale.wip\x20+\x20wip_hash\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20site,\x20or\x20wip_file\x20'+'type=\x27upload\x27\x20for\x20the\x20official\x20store).\x0a'+'\x20\x20•\x20Testing\x20only:\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20verification.';return{'content':[{'type':'text','text':o}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20host\x20unreachable\x20('+n+'):\x20'+h+'.\x20Customer\x20order_new\x20would\x20abort\x20100%\x20while\x20the\x20WIP\x20file\x20cannot\x20be\x20fetched\x20(F-27).\x20Not\x20a\x20wrong-network\x20problem.','error_code':'wip_host_unreachable','retryable':!![],'recovery_hint':'Transient\x20outage:\x20retry\x20after\x20the\x20host\x20recovers.\x20Permanent:\x20redeploy\x20the\x20.wip\x20'+'file\x20to\x20another\x20public\x20endpoint\x20and\x20set\x20sale.wip\x20to\x20the\x20new\x20URL\x20(update\x20'+'wip_hash\x20too);\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20host\x20unreachable\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}}if(!i['is_local'])continue;if(i['type']==='local_http'){if(f){c['push']('WIP\x20INTERNAL-TEST-ONLY\x20REMINDER\x20(sale\x20\x22'+g['name']+'\x22):\x20wip\x20=\x20\x22'+h+'\x22\x20is\x20a\x20'+('local-network\x20URL\x20('+i['description']+').\x20It\x20is\x20reachable\x20ONLY\x20on\x20the\x20')+'local\x20machine\x20/\x20LAN\x20where\x20a\x20local\x20WIP\x20server\x20runs.\x20This\x20is\x20acceptable\x20for\x20LOCALNET\x20'+'internal\x20testing,\x20but\x20customers\x20and\x20on-chain\x20verifiers\x20on\x20OTHER\x20machines\x20CANNOT\x20'+'reach\x20it\x20—\x20on\x20testnet/mainnet,\x20every\x20customer\x20order_new\x20would\x20fail\x20100%\x20because\x20the\x20'+'WIP\x20file\x20cannot\x20be\x20verified.\x20For\x20any\x20non-localnet\x20deployment,\x20replace\x20this\x20URL\x20with\x20'+'a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20or\x20leave\x20sale.wip\x20empty.');continue;}const p='a\x20local-network\x20URL\x20('+i['description']+')',q='⛔\x20WIP\x20IS\x20NOT\x20NETWORK-DEPLOYABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20which\x20is\x20'+p+'.\x0a\x0a')+'INTERNAL\x20TEST\x20USE\x20ONLY:\x20this\x20URL\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN.\x20'+'Customers\x20on\x20other\x20machines\x20cannot\x20reach\x20it,\x20so\x20verifying\x20the\x20WIP\x20file\x20at\x20order\x20time\x20'+'fails\x20and\x20order_new\x20aborts\x20100%.\x20Local-network\x20WIP\x20URLs\x20are\x20allowed\x20ONLY\x20for\x20'+('localnet\x20internal\x20testing\x20(env.network\x20=\x20\x22localnet\x22);\x20on\x20'+(b?.['network']??'this\x20network')+'\x20')+'they\x20must\x20never\x20be\x20stored\x20on-chain.\x0a\x0a'+'Fix:\x20deploy\x20the\x20.wip\x20file\x20to\x20a\x20publicly\x20reachable\x20endpoint,\x20then\x20re-run\x20with\x20'+'sale.wip\x20=\x20\x22<public\x20URL>\x22\x20(e.g.\x20GitHub\x20Pages,\x20IPFS\x20gateway,\x20or\x20your\x20own\x20website).\x0a'+'\x20\x20•\x20GitHub\x20Pages:\x20https://<user>.github.io/<repo>/<file>.wip\x0a'+'\x20\x20•\x20IPFS:\x20\x20\x20\x20\x20\x20\x20\x20https://ipfs.io/ipfs/<CID>\x20\x20(or\x20ipfs://<CID>)\x0a'+'\x20\x20•\x20Your\x20site:\x20\x20\x20https://<your-domain>/<path>/<file>.wip\x0a'+'Alternatively,\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20SKIP\x20WIP\x20verification\x20—\x20'+'TESTING\x20ONLY,\x20not\x20recommended\x20for\x20production.';return{'content':[{'type':'text','text':q}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20is\x20'+p+':\x20'+h+'.\x20Local-network\x20URLs\x20are\x20INTERNAL\x20TEST\x20USE\x20ONLY\x20—\x20customers\x20cannot\x20verify\x20them,\x20aborting\x20order_new\x20100%.','error_code':'wip_not_network_deployed','retryable':!![],'recovery_hint':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20'+'and\x20set\x20sale.wip\x20to\x20the\x20public\x20URL;\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20'+'verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20is\x20a\x20local-network\x20URL\x20(INTERNAL\x20TEST\x20USE\x20ONLY)\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}const k='a\x20LOCAL\x20'+i['type']+'\x20path',l='⛔\x20WIP\x20IS\x20NOT\x20NETWORK-DEPLOYABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20which\x20is\x20'+k+'.\x0a\x0a')+'Why\x20this\x20is\x20fatal:\x20the\x20WIP\x20path\x20is\x20stored\x20ON-CHAIN\x20and\x20every\x20customer\x20'+'(on\x20a\x20different\x20machine)\x20fetches\x20it\x20when\x20placing\x20an\x20order.\x20A\x20local\x20path\x20/\x20'+'localhost\x20/\x20LAN\x20URL\x20is\x20reachable\x20only\x20from\x20YOUR\x20machine\x20—\x20it\x20passes\x20the\x20'+'merchant-side\x20set-time\x20verification\x20but\x20makes\x20order_new\x20abort\x20100%\x20for\x20customers.\x0a\x0a'+'Fix:\x20deploy\x20the\x20.wip\x20file\x20to\x20a\x20publicly\x20reachable\x20endpoint,\x20then\x20re-run\x20with\x20'+'sale.wip\x20=\x20\x22<public\x20URL>\x22\x20(e.g.\x20GitHub\x20Pages,\x20IPFS\x20gateway,\x20or\x20your\x20own\x20website).\x0a'+'\x20\x20•\x20GitHub\x20Pages:\x20https://<user>.github.io/<repo>/<file>.wip\x0a'+'\x20\x20•\x20IPFS:\x20\x20\x20\x20\x20\x20\x20\x20https://ipfs.io/ipfs/<CID>\x20\x20(or\x20ipfs://<CID>)\x0a'+'\x20\x20•\x20Your\x20site:\x20\x20\x20https://<your-domain>/<path>/<file>.wip\x0a'+'Alternatively,\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20SKIP\x20WIP\x20verification\x20—\x20'+'TESTING\x20ONLY,\x20not\x20recommended\x20for\x20production.';return{'content':[{'type':'text','text':l}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20is\x20'+k+':\x20'+h+'.\x20Local\x20WIP\x20paths\x20are\x20unreachable\x20by\x20customers\x20and\x20abort\x20order_new\x20100%.','error_code':'wip_not_network_deployed','retryable':!![],'recovery_hint':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20'+'and\x20set\x20sale.wip\x20to\x20the\x20public\x20URL;\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20'+'verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20is\x20not\x20network-deployable\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}return null;}function checkSalesZeroPrice(a){const b=a?.['sales'];if(!b||typeof b!=='object')return null;if(b['op']!=='add'&&b['op']!=='set')return null;const c=Array['isArray'](b['sales'])?b['sales']:[];for(const d of c){const e=d?.['price']?.['balance']??d?.['price'],f=typeof e==='string'?e['trim']():String(e??'');if(!/^\d+$/['test'](f)||BigInt(f)!==0x0n)continue;const g='⛔\x20ZERO-PRICE\x20SKU\x20REFUSED\x20—\x20sales\x20NOT\x20submitted\x20(F-BS-76)\x0a\x0a'+('Sale\x20\x22'+d['name']+'\x22\x20has\x20price\x200.\x20A\x20zero-priced\x20SKU\x20is\x20LISTABLE\x20but\x20PERMANENTLY\x20UNBUYABLE:\x20')+'the\x20chain\x20refuses\x20zero-total\x20orders\x20(client\x20order_new_zero_total_dead_order,\x20on-chain\x20abort\x2042),\x20'+'so\x20no\x20buyer\x20can\x20ever\x20purchase\x20it\x20—\x20and\x20the\x20listing\x20is\x20immutable\x20on\x20those\x20points\x20that\x20matter\x20'+'(removing\x20it\x20costs\x20gas;\x20repricing\x20needs\x20a\x20fresh\x20set).\x0a\x0a'+'Fixes\x20(pick\x20one):\x0a'+'\x20\x20•\x20Price\x20it\x20at\x201\x20smallest\x20unit\x20(the\x20minimum\x20buyable\x20price)\x20—\x20the\x20standard\x20way\x20to\x20express\x20a\x20free\x20tier.\x0a'+'\x20\x20•\x20If\x20the\x20item\x20is\x20not\x20actually\x20for\x20sale,\x20do\x20not\x20add\x20it\x20to\x20sales.\x0a'+'\x20\x20•\x20Testing\x20an\x20unbuyable\x20listing\x20deliberately?\x20Re-run\x20with\x20price\x20\x221\x22\x20—\x20the\x20gate\x20arithmetic\x20is\x20identical\x20from\x20price\x201\x20upward.';return{'content':[{'type':'text','text':g}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+d['name']+'\x22\x20price\x200:\x20zero-priced\x20SKUs\x20are\x20permanently\x20unbuyable\x20(zero-total\x20gate,\x20abort\x2042)\x20—\x20F-BS-76.','error_code':'invalid_parameter','retryable':![],'recovery_hint':'Set\x20price\x20to\x20at\x20least\x201\x20smallest\x20unit\x20(a\x20free\x20tier\x20is\x20priced\x20at\x201,\x20not\x200)\x20and\x20resubmit;\x20'+'or\x20drop\x20the\x20item\x20from\x20sales\x20if\x20it\x20is\x20not\x20for\x20sale.','related_object':d['name']},'message':'Zero-price\x20SKU\x20refused\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}return null;}function extractObjectOnlyRef(a){const b=a;if(b['submission'])return undefined;const c=b['data'];if(!c||typeof c!=='object'||Array['isArray'](c))return undefined;const d=c,e=Object['keys'](d);if(e['length']!==0x1||e[0x0]!=='object')return undefined;const f=d['object'];return typeof f==='string'&&f['trim']()['length']>0x0?f['trim']():undefined;}async function queryObjectOnlyResult(a,b,c){let d=[],f;try{const j=await query_objects({'objects':[b],'network':c?.['network'],'no_cache':!![]});d=j['objects']??[],d['length']===0x0&&(f='Object\x20\x27'+b+'\x27\x20not\x20found\x20on-chain.\x20It\x20may\x20never\x20have\x20been\x20created,\x20'+'its\x20local\x20mark\x20may\x20be\x20missing\x20(register\x20it\x20via\x20local_mark_operation),\x20'+'or\x20it\x20may\x20live\x20on\x20a\x20different\x20network.');}catch(k){const l=k?.['message']??String(k);f='Query\x20failed\x20for\x20\x27'+b+'\x27:\x20'+l;}const g=d['map'](m=>({...m,'change':'queried'})),h=f?'Object-only\x20payload\x20for\x20'+a+'\x20—\x20nothing\x20to\x20mutate,\x20no\x20transaction\x20was\x20sent\x20(no\x20gas\x20used).\x20'+f:'Object-only\x20payload\x20for\x20'+a+'\x20—\x20nothing\x20to\x20mutate,\x20no\x20transaction\x20was\x20sent\x20(no\x20gas\x20used).\x20Current\x20on-chain\x20state\x20of\x20\x27'+b+'\x27:',i={'message':h,'result':f?{'type':'error','error':f,'error_code':'object_not_found','retryable':![],'recovery_hint':'Check\x20the\x20name\x20spelling\x20(local_mark_operation\x20list),\x20the\x20env.network\x20value,\x20or\x20create\x20the\x20object\x20first.'}:{'type':'data','data':g},'semantic':{'intent':a+'_read','status':f?'failed':'success','summary':h,'next_actions':[{'action':'Use\x20query_toolkit\x20(onchain_objects)\x20for\x20richer\x20inspection\x20—\x20content\x20fields,\x20ownership,\x20dynamic\x20tables.','reason':'Object-only\x20onchain_operations\x20payloads\x20are\x20answered\x20by\x20a\x20pure\x20query;\x20they\x20never\x20mutate\x20on-chain\x20state.','tool':'query_toolkit','priority':'recommended'}],'warnings':['Payload\x20contained\x20only\x20data.object\x20—\x20interpreted\x20as\x20a\x20READ\x20request,\x20not\x20a\x20transaction.']}};return{'content':[{'type':'text','text':h}],'structuredContent':i};}function checkOrderAllocatorsPrePublish(b,c){if(!b||typeof b!=='object')return null;let d,f;try{const h=assessAllocationRisks({'allocators_config':b,'operation_type':'create','trigger_source':'service_order_allocators'}),i=new Set(['R-A-1-01','R-A-1-02','R-A-1-03','R-A-2-03']);d=h['risks']['filter'](j=>i['has'](j['id']))['map'](j=>({'id':j['id'],'title':j['title'],'mitigation':j['mitigation']})),f=h['risks']['filter'](j=>!i['has'](j['id'])&&(j['level']==='critical'||j['level']==='high'))['map'](j=>({'id':j['id'],'title':j['title'],'mitigation':j['mitigation']}));}catch(j){return c['push']('pre-publish\x20allocators\x20risk\x20scan\x20failed\x20(non-blocking):\x20'+(j instanceof Error?j['message']:String(j))+'\x20—\x20'+'run\x20the\x20recipient\x20constraint\x20audit\x20via\x20query_toolkit\x20service_panorama\x20before\x20publish.'),null;}for(const k of f){c['push']('ALLOCATOR\x20RISK\x20'+k['id']+'\x20(advisory\x20—\x20needs\x20full-evidence\x20review\x20before\x20publish):\x20'+k['title']+'\x20—\x20'+k['mitigation']);}try{const l=Array['isArray'](b?.['allocators'])?b['allocators']:[],m=l['map']((n,o)=>{const p=Array['isArray'](n?.['sharing'])?n['sharing']:[];return p['some'](q=>q?.['who']&&typeof q['who']==='object'&&'GuardIdentifier'in q['who'])?o:-0x1;})['filter'](n=>n>=0x0);m['length']>0x0&&c['push']('REFUND\x20TRACK\x20GUARD\x20GATING\x20(advisory):\x20Allocator(s)\x20['+m['join'](',\x20')+']\x20pay\x20a\x20'+'GuardIdentifier\x20recipient\x20—\x20the\x20order-anchored\x20refund\x20track.\x20Verify\x20the\x20bound\x20guard\x20is\x20'+'NODE-GATED:\x20AND[progress.node==<X>]\x20per\x20refundable\x20node\x20(per-node\x20tracks\x20are\x20the\x20'+'default\x20form\x20—\x20a\x20node\x20set\x20is\x20also\x20expressible\x20via\x20the\x20relies\x20two-level\x20tree:\x20'+'OR-subguard\x20per\x20node\x20under\x20an\x20AND\x20parent).\x20A\x20signer==order.owner\x20leg\x20is\x20OPTIONAL\x20here,\x20'+'not\x20a\x20safety\x20requirement:\x20with\x20a\x20GuardIdentifier\x20recipient\x20the\x20payee\x20is\x20already\x20hard-bound\x20to\x20the\x20'+'order\x20(funds\x20land\x20in\x20the\x20order\x20no\x20matter\x20who\x20triggers),\x20so\x20the\x20signer\x20leg\x20only\x20restricts\x20who\x20may\x20'+'fire\x20the\x20trigger\x20—\x20drop\x20it\x20when\x20keepers\x20or\x20the\x20service\x20should\x20be\x20able\x20to\x20trigger\x20refunds.\x20There\x20is\x20'+'NO\x20on-chain\x20seal\x20between\x20the\x20refund\x20track\x20and\x20a\x20compensation\x20ruling\x20—\x20a\x20claim\x20settling\x20does\x20NOT\x20close\x20'+'this\x20track;\x20enforce\x20any\x20refund-vs-compensation\x20exclusion\x20by\x20gating\x20the\x20guard\x20(e.g.\x20on\x20arb/settlement\x20'+'state)\x20at\x20configuration\x20time.\x20Declare\x20the\x20identifier-254\x20once\x20slot\x20on\x20the\x20'+'refund\x20guard\x20(chain\x20derives\x20the\x20key\x20from\x20payment_info.for_object\x20—\x20unwidenable\x20per-order\x20replay\x20'+'protection;\x20reserve\x20identifier\x20255\x20with\x20a\x20period\x20key\x20for\x20rails\x20that\x20legitimately\x20repeat\x20per\x20period)\x20'+'so\x20a\x20consumed\x20claim\x20cannot\x20re-split\x20the\x20residual.');}catch{}if(d['length']===0x0)return null;const g='⛔\x20SERVICE\x20PUBLISH\x20BLOCKED\x20—\x20order_allocators\x20fails\x20the\x20pre-publish\x20risk\x20scan\x20'+'(the\x20allocation\x20rule\x20kernel,\x20same\x20rules\x20as\x20the\x20template\x20scan).\x0a\x0a'+d['map'](n=>'\x20\x20•\x20'+n['id']+':\x20'+n['title']+'\x0a\x20\x20\x20\x20Fix:\x20'+n['mitigation'])['join']('\x0a')+'\x0a\x0aorder_allocators\x20is\x20PERMANENTLY\x20IMMUTABLE\x20after\x20publish\x20(E_ALREADY_PUBLISHED,\x20'+'no\x20pause+lock\x20exception)\x20—\x20a\x20published\x20misconfiguration\x20locks\x20order\x20funds\x20or\x20aborts\x20'+'every\x20alloc()\x20transaction\x20for\x20the\x20lifetime\x20of\x20this\x20Service.\x20Fix\x20the\x20allocator\x20table\x20'+'and\x20re-issue\x20this\x20operation.\x20This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20action\x20was\x20taken.';return{'content':[{'type':'text','text':g}],'structuredContent':{'result':{'type':'error','error':d['map'](n=>n['id']+':\x20'+n['title'])['join']('\x20|\x20'),'error_code':'allocators_risk_blocked','retryable':!![],'recovery_hint':JSON['stringify'](d)},'message':'Service\x20publish\x20blocked\x20by\x20the\x20pre-publish\x20allocators\x20risk\x20scan.'}};}async function checkEntityRecipientGate(a,b,c){let d;try{d=await checkEntityRecipients(a);}catch(i){return c?.['push']('R-RECIPIENT-03\x20recipient\x20gate\x20failed\x20(non-blocking):\x20'+(i instanceof Error?i['message']:String(i))),null;}if(d['length']===0x0)return null;const f=d['filter'](j=>j['severity']==='critical'),g=d['filter'](j=>j['severity']!=='critical');for(const j of g){c?.['push'](formatEntityRecipientViolation(j)+'\x20—\x20fix\x20before\x20committing\x20this\x20allocator\x20table.');}if(f['length']===0x0)return null;const h='⛔\x20OPERATION\x20BLOCKED\x20—\x20'+b+'\x20violates\x20'+ENTITY_RECIPIENT_RULE_ID+'\x20'+'(direct-sales\x20Entity\x20recipient\x20rule).\x0a\x0a'+f['map'](k=>'\x20\x20•\x20'+formatEntityRecipientViolation(k))['join']('\x0a')+(g['length']>0x0?'\x0a\x0aAlso\x20reported\x20(non-blocking):\x0a'+g['map'](k=>'\x20\x20•\x20'+formatEntityRecipientViolation(k))['join']('\x0a'):'')+('\x0a\x0a'+describeEntityRecipients(f)+'\x0a\x0a')+'order_allocators\x20is\x20PERMANENTLY\x20IMMUTABLE\x20after\x20publish\x20(no\x20pause+lock\x20escape)\x20—\x20'+'an\x20empty\x20Entity\x20recipient\x20published\x20now\x20silently\x20pays\x20the\x20builder\x20forever.\x20Fix\x20the\x20'+'recipient\x20table\x20and\x20re-issue\x20this\x20operation.\x20This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20'+'action\x20was\x20taken.';return{'content':[{'type':'text','text':h}],'structuredContent':{'result':{'type':'error','error':f['map'](k=>k['rule_id']+'\x20allocator['+k['allocator_index']+'].sharing['+k['sharing_index']+']:\x20'+k['reason'])['join']('\x20|\x20'),'error_code':'entity_recipient_invalid','retryable':!![],'recovery_hint':describeEntityRecipients(f)},'message':'Operation\x20blocked\x20by\x20'+ENTITY_RECIPIENT_RULE_ID+':\x20an\x20Entity\x20recipient\x20is\x20empty,\x20omitted,\x20or\x20resolves\x20to\x20the\x20deploying\x20account.'}};}function warnAmountEscrowDeadlock(a,b,c){try{const d=Array['isArray'](a?.['allocators'])?a['allocators']:[],e=d['map'](k=>(Array['isArray'](k?.['sharing'])?k['sharing']:[])['filter'](l=>l?.['mode']==='Amount')['reduce']((l,m)=>l+(Number(m?.['sharing']?.['balance'])||0x0),0x0)),f=e['some'](k=>k>0x0);if(!f)return;const g=Array['isArray'](b?.['sales'])?b['sales']:[],h=g['map'](k=>Number(k?.['price']?.['balance']))['filter'](k=>Number['isFinite'](k)&&k>0x0);if(h['length']===0x0)return;const j=h['reduce']((k,l)=>k+l,0x0);for(let k=0x0;k<e['length'];k++){e[k]>j&&c['push']('FIXED-AMOUNT\x20DEADLOCK\x20RISK\x20(advisory):\x20Allocator['+k+']\x20Amount\x20sum='+e[k]+'\x20exceeds\x20the\x20'+('minimum\x20single-order\x20escrow\x20Σ(price×1)='+j+'\x20(sales\x20configured\x20in\x20this\x20call;\x20quantity\x20fixed\x20at\x20buy\x20time).\x20')+'An\x20order\x20smaller\x20than\x20the\x20Amount\x20aborts\x20alloc()\x20with\x20Insufficient\x20balance\x20—\x20if\x20this\x20allocator\x20is\x20the\x20only\x20'+'match\x20on\x20a\x20terminal\x20forward,\x20that\x20order\x27s\x20balance\x20is\x20permanently\x20stranded.\x20Use\x20Rate\x20sharing\x20for\x20'+'penalty/proportional\x20rules\x20(scales\x20with\x20the\x20order),\x20or\x20bound\x20the\x20Amount\x20below\x20the\x20smallest\x20expected\x20order.');}}catch{}}async function checkArbitrationsBeforePublish(a,b,c){if(!Array['isArray'](a)||a['length']===0x0)return null;const d=await resolveNetwork(b?.['network']),e=[],f=[],g=[],h=[];for(const i of a){let j;if(typeof i==='string')j=i['startsWith']('0x')?i:await LocalMark['Instance']()['get_address'](i)['catch'](()=>undefined)??undefined;else{if(i&&typeof i==='object'){const k=i['name']??i['object']??i['address'];typeof k==='string'&&(j=k['startsWith']('0x')?k:await LocalMark['Instance']()['get_address'](k)['catch'](()=>undefined)??undefined);}}if(!j){g['push'](typeof i==='string'?i:JSON['stringify'](i));continue;}try{const l=await query_objects({'objects':[j],'network':d,'no_cache':!![]}),m=l?.['objects']?.[0x0];if(!m||m['type']!=='Arbitration'){g['push'](j);continue;}const n=m['data']??m;if(n['bPaused']===!![])e['push'](j);const o=Array['isArray'](n['voting_guard'])?n['voting_guard']['length']:0x0;if(o===0x0)f['push'](j);const p=typeof n['permission']==='string'?n['permission']:undefined;if(p){const s=await query_objects({'objects':[p],'network':d,'no_cache':!![]}),t=s?.['objects']?.[0x0],u=t?.['data']??t,v=Array['isArray'](u?.['admin'])?u['admin']:[],w=await fetchEntityPermissions(p,d);w['size']===0x0&&h['push'](j+'\x20(admin:\x20'+(v['length']>0x0?v['join'](',\x20'):'unresolved')+')');}}catch{g['push'](j);}}g['length']>0x0&&c['push']('PRE-PUBLISH:\x20Could\x20not\x20resolve/query\x20bound\x20Arbitration(s)\x20['+g['join'](',\x20')+']\x20—\x20'+'verify\x20each\x20is\x20UNPAUSED\x20(new\x20Arbitrations\x20default\x20to\x20bPaused=true;\x20disputes\x20abort\x20with\x20E_PAUSED)\x20'+'and\x20that\x20voting\x20can\x20actually\x20happen:\x20an\x20empty\x20voting_guard\x20means\x20EQUAL\x20vote\x20weight\x20(1\x20person\x201\x20vote),\x20'+'but\x20plain\x20voting\x20still\x20asserts\x20permission\x20358\x20—\x20only\x20the\x20arbitration\x27s\x20bound\x20Permission\x20admin\x20'+'(its\x20creator,\x20by\x20default)\x20and\x20explicit\x20358\x20grantees\x20can\x20vote,\x20so\x20grant\x20358\x20to\x20the\x20disputing\x20'+'parties\x20or\x20configure\x20a\x20voting_guard\x20before\x20relying\x20on\x20a\x20working\x20vote.');f['length']>0x0&&c['push']('C7\x20RISK\x20(concentrated\x20voting):\x20Arbitration(s)\x20['+f['join'](',\x20')+']\x20have\x20an\x20EMPTY\x20voting_guard\x20—\x20'+'this\x20means\x20EQUAL\x20vote\x20weight\x20(1\x20person\x201\x20vote),\x20NOT\x20permissionless.\x20Plain\x20voting\x20asserts\x20'+'permission\x20358\x20on\x20the\x20arbitration\x27s\x20bound\x20Permission,\x20whose\x20admin\x20ALWAYS\x20passes\x20the\x20assert\x20'+'(a\x20fresh\x20Permission\x20seeds\x20its\x20creator\x20as\x20the\x20sole\x20admin;\x20the\x20permission\x20table\x20itself\x20starts\x20empty).\x20'+'So\x20without\x20explicit\x20grants\x20the\x20disputing\x20CUSTOMER\x20can\x20never\x20vote\x20(aborts\x20with\x20code\x205)\x20and\x20every\x20'+'dispute\x20devolves\x20to\x20admin-only\x20voting\x20—\x20the\x20arb\x20admin\x20is\x20both\x20the\x20only\x20voter\x20AND\x20the\x20judge.\x20The\x20'+'service\x20publish\x20gate\x20blocks\x20this\x20shape\x20outright\x20(R-ARB-VOTE-LOCK)\x20when\x20the\x20arb\x20admin\x20also\x20controls\x20'+'the\x20service\x20side;\x20this\x20warning\x20covers\x20the\x20general\x20case.\x20Fix:\x20'+'(1)\x20grant\x20permission\x20358\x20to\x20each\x20disputing\x20party\x20(equal-weight\x20vote\x20among\x20the\x20granted\x20parties),\x20'+'and\x20grant\x20the\x20non-admin\x20operator\x20slots\x20separately\x20—\x20359\x20(ruling)\x20+\x20361\x20(confirm\x20materials)\x20to\x20an\x20'+'EXTERNAL\x20arbitrator,\x20356/357/362-366\x20to\x20any\x20non-admin\x20manager\x20(the\x20creator-admin\x20needs\x20no\x20grants);\x20'+'or\x20(2)\x20for\x20weighted\x20voting,\x20set\x20voting_guard\x20via\x20arbitration\x20voting_guard\x20op=\x22add\x22\x20with\x20'+'a\x20verifier\x20Guard\x20+\x20vote_weight\x20(GuardIdentifier\x20for\x20submitted\x20weights,\x20or\x20FixedValue)\x20—\x20weighted\x20'+'voters\x20then\x20call\x20vote\x20WITH\x20data.vote.voting_guard\x20(plain\x20vote\x20aborts\x20E_VOTING_GUARD_USED\x20once\x20a\x20'+'voting_guard\x20exists;\x20the\x20weighted\x20path\x20authorizes\x20via\x20the\x20guard\x20and\x20does\x20NOT\x20require\x20358).');h['length']>0x0&&c['push']('ADJUDICABILITY\x20RISK\x20(F-34,\x20nnd-tn-261025):\x20bound\x20Arbitration(s)\x20['+h['join'](',\x20')+']\x20hold\x20'+'ZERO\x20adjudication\x20entities\x20on\x20their\x20Permission\x20—\x20the\x20entity\x20table\x20is\x20empty,\x20so\x20NOBODY\x20except\x20the\x20'+'admin\x20can\x20confirm\x20materials,\x20vote,\x20or\x20rule.\x20Disputes\x20can\x20still\x20be\x20FILED\x20(the\x20fee\x20escrows),\x20but\x20'+'there\x20is\x20no\x20on-chain\x20timeout\x20fallback:\x20with\x20an\x20unreachable\x20admin\x20a\x20case\x20stalls\x20forever\x20and\x20the\x20'+'escrowed\x20fee\x20is\x20stranded\x20(nnd-arb\x20live\x20case:\x20a\x20case\x20was\x20filed\x20and\x20paid,\x20no\x20ruling\x20was\x20ever\x20'+'possible).\x20Remedy\x20BEFORE\x20relying\x20on\x20disputes:\x20if\x20the\x20admin\x20account\x20is\x20yours,\x20grant\x20at\x20least\x20one\x20'+'adjudication\x20entity\x20(permission\x20add\x20perm\x20on\x20the\x20arb\x27s\x20Permission:\x20358\x20vote\x20/\x20359\x20ruling\x20/\x20'+'361\x20confirm\x20materials);\x20if\x20the\x20admin\x20is\x20an\x20external\x20third\x20party,\x20confirm\x20they\x20have\x20configured\x20'+'their\x20entity\x20table\x20—\x20otherwise\x20bind\x20an\x20adjudicable\x20arbitration\x20instead.\x20Entities\x20can\x20also\x20be\x20'+'granted\x20after\x20publish,\x20so\x20this\x20is\x20a\x20disclosure,\x20not\x20a\x20blocker\x20—\x20but\x20publishing\x20a\x20Service\x20whose\x20'+'only\x20dispute\x20path\x20is\x20a\x20dead\x20arbitration\x20is\x20a\x20commercial\x20hole\x20buyers\x20inherit.');if(e['length']>0x0){const x='⛔\x20SERVICE\x20PUBLISH\x20BLOCKED\x20—\x20bound\x20Arbitration(s)\x20['+e['join'](',\x20')+']\x20are\x20PAUSED.\x0a\x0a'+'A\x20newly\x20created\x20Arbitration\x20defaults\x20to\x20bPaused=true;\x20while\x20paused,\x20EVERY\x20dispute\x20filing\x20aborts\x20'+'with\x20E_PAUSED\x20—\x20the\x20arbitration\x20mounted\x20on\x20this\x20Service\x20would\x20be\x20decorative\x20(buyers\x20have\x20no\x20'+'working\x20dispute\x20path,\x20and\x20compensation_fund\x20payouts\x20could\x20never\x20be\x20triggered).\x20The\x20on-chain\x20'+'publish\x20check\x20only\x20verifies\x20the\x20arbitrations\x20list\x20is\x20non-empty,\x20NOT\x20that\x20each\x20Arbitration\x20is\x20'+'active\x20—\x20this\x20scan\x20closes\x20that\x20gap.\x0a'+'Fix:\x20issue\x20{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20pause:false}}\x20for\x20each\x20paused\x20'+'Arbitration\x20above,\x20then\x20retry\x20publish=true.\x20This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20action\x20was\x20taken.';return{'content':[{'type':'text','text':x}],'structuredContent':{'result':{'type':'error','error':'arbitration_paused:\x20'+e['join'](',\x20'),'error_code':'arbitrations_paused','retryable':!![],'recovery_hint':JSON['stringify']({'paused':e,'unpaused_hint':'arbitration\x20data:{object,\x20pause:false}'})},'message':'Service\x20publish\x20blocked:\x20bound\x20Arbitration(s)\x20are\x20paused.'}};}return null;}async function checkRefundRecipientSatisfiability(a,b,c){if(!a||typeof a!=='object')return null;const d=Array['isArray'](a?.['allocators'])?a['allocators']:[],e=[];for(let l=0x0;l<d['length'];l++){const m=Array['isArray'](d[l]?.['sharing'])?d[l]['sharing']:[],n=d[l]?.['guard'];if(typeof n!=='string'||n['length']===0x0)continue;for(const o of m){const p=o?.['who'];p&&typeof p==='object'&&'GuardIdentifier'in p&&e['push']({'allocIdx':l,'guardRef':n,'identifier':p['GuardIdentifier']});}}if(e['length']===0x0)return null;const f=await resolveNetwork(b?.['network']),g=[],h=[],j=new Map();for(const r of e){try{let u=j['get'](r['guardRef']);if(u===undefined){let w=r['guardRef'];!w['startsWith']('0x')&&(w=await LocalMark['Instance']()['get_address'](w)['catch'](()=>undefined)??'');if(!w['startsWith']('0x')){h['push'](r['guardRef']);continue;}const x=await query_objects({'objects':[w],'network':f,'no_cache':!![]}),y=x?.['objects']?.[0x0];if(!y||y['type']!=='Guard'){h['push'](r['guardRef']);continue;}u=y['data']??y,j['set'](r['guardRef'],u);}const v=Array['isArray'](u['table'])?u['table']['find'](z=>z?.['identifier']===r['identifier']):undefined;if(!v||v['b_submission']!==!![])continue;pinsIdentifierToSigner(u['root'],r['identifier'])&&g['push']('Allocator['+r['allocIdx']+']\x20guard\x20'+r['guardRef']+'\x20pins\x20recipient\x20identifier\x20'+r['identifier']+'\x20to\x20context(Signer)');}catch{h['push'](r['guardRef']);}}h['length']>0x0&&c['push']('PRE-PUBLISH:\x20could\x20not\x20fetch\x20Guard(s)\x20['+h['join'](',\x20')+']\x20referenced\x20by\x20GuardIdentifier\x20'+'recipient\x20rows\x20—\x20manually\x20verify\x20each\x20refund\x20guard\x20does\x20NOT\x20pin\x20its\x20recipient\x20identifier\x20to\x20'+'context(Signer)\x20(unsatisfiable\x20against\x20the\x20order-anchored\x20escrow:\x20the\x20submission\x20must\x20equal\x20the\x20'+'Order\x20address,\x20never\x20the\x20signer\x20EOA).');if(g['length']===0x0)return null;const k='⛔\x20SERVICE\x20PUBLISH\x20BLOCKED\x20—\x20refund\x20recipient\x20unsatisfiable\x20(GuardIdentifier\x20x\x20for_object\x20x\x20Guard\x20equality).\x0a\x0a'+g['map'](z=>'\x20\x20•\x20'+z)['join']('\x0a')+'\x0a\x0aThe\x20framework-created\x20order\x20escrow\x20anchors\x20PaymentInfo.for_object\x20to\x20the\x20ORDER\x20object\x20address\x20and\x20'+'the\x20chain\x20asserts\x20every\x20GuardIdentifier\x20recipient\x20submission\x20==\x20that\x20address\x20(ERECIPIENT_NOT_FOR_OBJECT,\x20'+'code\x2015).\x20The\x20guard(s)\x20above\x20ALSO\x20require\x20the\x20same\x20submitted\x20value\x20==\x20context(Signer)\x20—\x20an\x20Order\x20address\x20'+'is\x20never\x20the\x20signer\x20EOA,\x20so\x20the\x20allocator\x20can\x20NEVER\x20execute\x20and\x20order\x20funds\x20strand\x20permanently\x20'+'(order_allocators\x20is\x20immutable\x20after\x20publish;\x20test/10\x20T10-10/T10-18\x20stranded\x200.79\x20WOW\x20this\x20way).\x0a'+'Fix\x20(verified\x20ORDER\x20PATTERN,\x20test/10\x20T10-17):\x20keep\x20the\x20recipient\x20GuardIdentifier(n)\x20as-is,\x20and\x20in\x20the\x20'+'GUARD\x20replace\x20logic_equal(context(Signer),\x20identifier[n])\x20with\x20an\x20ORDER\x20FIELD\x20query\x20binding\x20—\x20'+'logic_equal(order.owner,\x20context(Signer))\x20—\x20then\x20submit\x20the\x20ORDER\x20ADDRESS\x20for\x20identifier\x20n.\x20Funds\x20land\x20'+'in\x20the\x20Order\x20object\x20and\x20the\x20buyer\x20withdraws\x20via\x20order\x20receive:\x27recently\x27.\x0a'+'This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20action\x20was\x20taken.';return{'content':[{'type':'text','text':k}],'structuredContent':{'result':{'type':'error','error':'refund_recipient_unsatisfiable:\x20'+g['join'](';\x20'),'error_code':'refund_recipient_unsatisfiable','retryable':!![],'recovery_hint':'Rebuild\x20the\x20refund\x20Guard\x20with\x20order.owner==context(Signer)\x20identity\x20binding\x20and\x20submit\x20the\x20Order\x20address\x20for\x20the\x20recipient\x20identifier;\x20then\x20re-issue\x20service\x20publish'},'message':'Service\x20publish\x20blocked:\x20refund\x20recipient\x20guard\x20contradicts\x20the\x20order-anchored\x20escrow\x20binding.'}};}function pinsIdentifierToSigner(a,b){const c=f=>f?.['type']==='context'&&f?.['context']==='Signer',d=f=>f?.['type']==='identifier'&&f?.['identifier']===b,e=f=>{if(!f||typeof f!=='object')return![];if(f['type']==='logic_equal'||f['type']==='logic_as_u256_equal'){const g=Array['isArray'](f['nodes'])?f['nodes']:[];for(let h=0x0;h<g['length'];h++){for(let k=h+0x1;k<g['length'];k++){if(c(g[h])&&d(g[k]))return!![];if(d(g[h])&&c(g[k]))return!![];}}}if(Array['isArray'](f['nodes'])&&f['nodes']['some'](e))return!![];if(f['node']&&e(f['node']))return!![];if(Array['isArray'](f['parameters'])&&f['parameters']['some'](e))return!![];return![];};return e(a);}function describeArbitrationPayload(a){if(Array['isArray'](a))return a['length']+'\x20item(s)';if(a&&typeof a==='object'&&Array['isArray'](a['objects']))return a['objects']['length']+'\x20item(s)';return'<none>';}function canonicalRecipientKey(a){if(typeof a==='string')return a;const b=classifyRecipient(a);if(b?.['kind']==='entity')return'Entity:'+b['address'];if(b?.['kind']==='signer')return'Signer';if(b?.['kind']==='submission')return'GuardIdentifier:'+b['identifier'];return a!=null?JSON['stringify'](a):undefined;}function normHexAddr(b){return b['toLowerCase']()['replace'](/^0x/,'')['padStart'](0x40,'0');}async function describeAllocatorsNotExtensionDiff(a,b,c){try{if(!a||typeof a!=='object')return undefined;const d=a['object']??a['name'],e=typeof d==='string'?/^0x[0-9a-fA-F]{1,64}$/['test'](d)?d:await LocalMark['Instance']()['get_address'](d):undefined;if(!e)return undefined;const f=b,g=Array['isArray'](f?.['allocators'])?f['allocators']:null;if(!g)return undefined;const h=await query_objects({'objects':[e],'network':c}),k=(h?.['objects']??[])['find'](r=>r?.['object']===e),m=k?.['order_allocators'],n=Array['isArray'](m?.['allocators'])?m['allocators']:null;if(!n)return undefined;const o=[],p=readRawOnchainAmount(m?.['threshold']),q=readRawOnchainAmount(f?.['threshold']);p!==undefined&&q!==undefined&&p!==q&&o['push']('threshold\x20mismatch:\x20submitted\x20'+q+'\x20vs\x20live\x20'+p+'\x20(append\x20requires\x20the\x20SAME\x20threshold)');g['length']<n['length']&&o['push']('length\x20mismatch:\x20submitted\x20'+g['length']+'\x20rail(s)\x20vs\x20live\x20'+n['length']+'\x20(append\x20requires\x20length-or-longer\x20with\x20the\x20live\x20prefix\x20preserved)');if(o['length']===0x0){const r=Math['min'](g['length'],n['length']);for(let t=0x0;t<r&&o['length']===0x0;t++){const u=g[t],v=n[t],w=typeof u?.['guard']==='string'?u['guard']:undefined,x=typeof v?.['guard']==='string'?v['guard']:undefined;if(w&&x&&normHexAddr(w)!==normHexAddr(x)){o['push']('rail\x20'+t+'\x20guard\x20rewritten:\x20submitted\x20'+w+'\x20vs\x20live\x20'+x+'\x20(existing\x20allocators\x20must\x20be\x20preserved\x20verbatim\x20as\x20a\x20prefix)');break;}const y=Array['isArray'](u?.['sharing'])?u['sharing']:[],z=Array['isArray'](v?.['sharing'])?v['sharing']:[];if(y['length']!==z['length']){o['push']('rail\x20'+t+'\x20sharing\x20rows:\x20submitted\x20'+y['length']+'\x20vs\x20live\x20'+z['length']);break;}for(let A=0x0;A<Math['min'](y['length'],z['length'])&&o['length']===0x0;A++){const B=canonicalRecipientKey(y[A]?.['who']),C=canonicalRecipientKey(z[A]?.['who']);if(B&&C&&B!==C){o['push']('rail\x20'+t+'\x20row\x20'+A+'\x20recipient\x20rewritten:\x20submitted\x20'+B+'\x20vs\x20live\x20'+C);break;}const D=readRawOnchainAmount(y[A]?.['sharing']),E=readRawOnchainAmount(z[A]?.['sharing']);if(D!==undefined&&E!==undefined&&D!==E){o['push']('rail\x20'+t+'\x20row\x20'+A+'\x20share\x20rewritten:\x20submitted\x20'+D+'\x20vs\x20live\x20'+E);break;}}}}return o['length']===0x0&&o['push']('no\x20field-level\x20divergence\x20found\x20against\x20the\x20live\x20plan\x20—\x20rebuild\x20the\x20payload\x20from\x20the\x20LIVE\x20plan\x20(query_toolkit\x20service_panorama\x20→\x20result.service.order_allocators,\x20authoring\x20form)\x20and\x20re-submit'),'APPEND\x20REJECTED\x20(EALLOCATORS_NOT_EXTENSION):\x20the\x20submitted\x20plan\x20is\x20NOT\x20a\x20pure\x20extension\x20of\x20the\x20live\x20order_allocators.\x20First\x20divergence:\x20'+o['join'](';\x20')+'.\x20'+'Append\x20shape:\x20same\x20threshold,\x20length-or-longer,\x20every\x20existing\x20allocator\x20preserved\x20verbatim\x20as\x20a\x20prefix,\x20new\x20rails\x20appended\x20after.';}catch{return undefined;}}function readRawOnchainAmount(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&/^\d+$/['test'](a['trim']()))return Number(a['trim']());if(a&&typeof a==='object')for(const b of['value','balance','amount']){const c=a[b];if(typeof c==='number'&&Number['isFinite'](c))return c;if(typeof c==='string'&&/^\d+$/['test'](c['trim']()))return Number(c['trim']());}return undefined;}async function expandBareReceiveIds(a,b){const c=a?.['data'];if(!c||typeof c!=='object')return;const d=['receive','owner_receive'],e=[],f=[];for(const l of d){const m=c[l];typeof m==='string'&&/^0x[0-9a-fA-F]{8,}$/['test'](m)&&(e['push'](m),f['push']({'field':l}));}if(e['length']===0x0)return;const g=b??undefined,h=await Config['Instance']()['network_get'](g),j=new WowClient({'url':getFullnodeUrl(h),'network':h}),{objects:k}=await j['core']['getObjects']({'objectIds':e,'include':{'json':!![]}});for(let n=0x0;n<e['length'];n++){const p=f[n]['field'],q=k[n];if(!q||typeof q!=='object'||!q?.['objectId']||!q?.['type'])throw new Error('receive:\x20bare\x20object\x20id\x20\x27'+e[n]+'\x27\x20(field\x20\x27'+p+'\x27)\x20could\x20not\x20be\x20resolved\x20'+('on\x20'+h+'\x20—\x20pass\x20the\x20full\x20received\x20record\x20({id,\x20type,\x20version,\x20digest}),\x20')+'or\x20\x27recently\x27\x20to\x20sweep\x20everything\x20the\x20object\x20received.');c[p]=[{'id':String(q['objectId']),'type':String(q['type']),'content_raw':q['json']??undefined,'version':q['version']!=null?String(q['version']):undefined,'digest':q['digest']!=null?String(q['digest']):undefined}];}}export async function deriveTotalPayIfOmitted(a,b){const c=a?.['order_new']?.['buy'];if(!c)return undefined;if(c['total_pay']!=null){if(c['discount']!=null)return undefined;const e=await catalogTotalWalk(c,a,b)['catch'](()=>null);if(e===null||'error'in e)return undefined;const f=parseTotalPayRaw(c);if(f===undefined||f===e['total'])return undefined;const g=f>e['total']?f-e['total']:e['total']-f;return'total_pay\x20OVERRIDE:\x20explicit\x20'+f+'\x20replaces\x20the\x20catalog\x20derivation\x20'+('Σ\x20price×quantity\x20=\x20'+e['total']+'\x20('+e['lines']['join']('\x20+\x20')+')\x20—\x20drift\x20'+g+'\x20')+(f>e['total']?'ABOVE\x20the\x20catalog\x20total;\x20the\x20excess\x20escrows\x20with\x20the\x20order.\x20Confirm\x20this\x20is\x20intended.':'BELOW\x20the\x20catalog\x20total\x20—\x20without\x20a\x20discount\x20the\x20on-chain\x20quote\x20rejects\x20underpayment\x20(the\x20buy\x20aborts).');}if(c['discount']!=null)throw new Error('buy.total_pay\x20is\x20REQUIRED\x20when\x20a\x20discount\x20is\x20applied\x20—\x20the\x20discounted\x20final\x20total\x20depends\x20on\x20the\x20'+'coupon\x27s\x20live\x20value\x20and\x20must\x20be\x20stated\x20explicitly.\x20Run\x20query_toolkit\x20query_type=\x27service_quote\x27\x20'+'and\x20pass\x20total_pay.balance\x20=\x20the\x20quoted\x20final_total.');const d=await catalogTotalWalk(c,a,b);if('error'in d)throw new Error(d['error']);return c['total_pay']={'balance':d['total']['toString']()},'total_pay\x20auto-derived\x20=\x20'+d['total']['toString']()+'\x20(smallest\x20unit;\x20Σ\x20price×quantity:\x20'+d['lines']['join']('\x20+\x20')+';\x20'+'no\x20discount).\x20Pass\x20total_pay\x20explicitly\x20to\x20pin\x20the\x20amount\x20—\x20REQUIRED\x20when\x20using\x20a\x20discount.';}async function catalogTotalWalk(a,b,c){const d=Array['isArray'](a['items'])?a['items']:[];if(d['length']===0x0)return{'error':'buy.total_pay\x20is\x20omitted\x20and\x20the\x20cart\x20has\x20NO\x20items\x20—\x20there\x20is\x20nothing\x20to\x20derive\x20the\x20payment\x20from'};const e=b?.['object'];if(typeof e!=='string'||e['length']===0x0)return{'error':'buy.total_pay\x20is\x20omitted\x20but\x20the\x20Service\x20reference\x20(data.object)\x20is\x20missing\x20—\x20cannot\x20derive\x20the\x20payment'};const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return{'error':'Service\x20\x27'+e+'\x27\x20could\x20not\x20be\x20resolved\x20—\x20cannot\x20derive\x20total_pay'};const g=await query_serviceContext({'service':f,'network':c}),h=g?.['service'];if(!h)return{'error':'Service\x20\x27'+e+'\x27\x20not\x20found\x20—\x20cannot\x20derive\x20total_pay'};const i=Array['isArray'](h['sales'])?h['sales']:[];let j=0x0n;const k=[];for(const l of d){const m=l?.['name'],n=i['find'](q=>q?.['name']===m);if(!n)return{'error':'cannot\x20derive\x20total_pay:\x20item\x20\x27'+m+'\x27\x20matches\x20NO\x20sale\x20on\x20service\x20\x27'+e+'\x27\x20'+('(available:\x20'+(i['map'](q=>q?.['name'])['filter'](Boolean)['join'](',\x20')||'<none>')+')')};if(n?.['suspension']===!![])return{'error':'cannot\x20derive\x20total_pay:\x20item\x20\x27'+m+'\x27\x20is\x20suspended\x20on\x20service\x20\x27'+e+'\x27'};const o=BigInt(String(n?.['price']?.['balance']??n?.['price']??'0')),p=BigInt(String(l?.['quantity']??l?.['stock']??'1'));if(p<=0x0n)return{'error':'cannot\x20derive\x20total_pay:\x20item\x20\x27'+m+'\x27\x20has\x20non-positive\x20quantity\x20'+p};j+=o*p,k['push'](m+'\x20x'+p+'\x20@\x20'+o);}if(j<=0x0n)return{'error':'derived\x20total_pay\x20would\x20be\x200\x20(all\x20matched\x20sales\x20priced\x200)\x20—\x20pass\x20total_pay\x20explicitly'};return{'total':j,'lines':k};}async function probeOrderNewWipReachability(a,b){const c=a?.['order_new']?.['buy'],d=Array['isArray'](c?.['items'])?c['items']:[];if(d['length']===0x0)return null;const e=a?.['object'];if(typeof e!=='string'||e['length']===0x0)return null;try{const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return null;const g=await query_serviceContext({'service':f,'network':b}),h=Array['isArray'](g?.['service']?.['sales'])?g['service']['sales']:[],i=new Map();for(const j of d){const k=h['find'](o=>o?.['name']===j?.['name']),l=typeof k?.['wip']==='string'?k['wip']:'';if(!l)continue;const m=classifyWipPath(l),n=!m['is_local']&&m['is_network']&&(m['type']==='http_url'||m['type']==='ipfs'&&/^https?:/i['test'](l));if(n)i['set'](String(k['name']??j?.['name']??''),l);}for(const [o,p]of i){const q=await probeWipReachability(p)['catch'](()=>({'ok':![],'reason':'probe\x20failed'}));if(q['ok'])continue;const r=q['status']?'HTTP\x20'+q['status']:q['reason']??'unreachable',s='⛔\x20WIP\x20HOST\x20UNREACHABLE\x20—\x20order\x20NOT\x20created\x20(no\x20money\x20moved)\x0a\x0a'+('The\x20WIP\x20file\x20for\x20sale\x20\x22'+o+'\x22\x20('+p+')\x20is\x20not\x20reachable\x20('+r+').\x20')+'Creating\x20this\x20order\x20would\x20abort\x20100%\x20inside\x20the\x20WIP\x20verification\x20step\x20(F-27:\x20'+'WIP\x20single-host\x20outage\x20—\x20when\x20the\x20host\x20is\x20down,\x20NOBODY\x20can\x20buy\x20from\x20this\x20Service).\x0a\x0a'+'This\x20is\x20NOT\x20a\x20wrong-network\x20problem\x20—\x20do\x20NOT\x20switch\x20networks\x20and\x20do\x20NOT\x20retry\x20blindly.\x0a\x0a'+'Fix:\x0a'+'\x20\x20•\x20Transient\x20outage:\x20retry\x20this\x20order\x20after\x20the\x20host\x20recovers.\x0a'+'\x20\x20•\x20Otherwise:\x20the\x20MERCHANT\x20must\x20redeploy\x20the\x20.wip\x20file\x20to\x20another\x20public\x20endpoint\x20'+'and\x20update\x20sale.wip\x20+\x20wip_hash\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20their\x20own\x20site,\x20or\x20wip_file\x20'+'type=\x27upload\x27\x20for\x20the\x20official\x20store).\x0a'+'\x20\x20•\x20Testing\x20only:\x20the\x20merchant\x20can\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20verification.';return{'content':[{'type':'text','text':s}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+o+'\x22\x20wip\x20host\x20unreachable\x20('+r+'):\x20'+p+'.\x20order_new\x20would\x20abort\x20100%\x20in\x20WIP\x20verification\x20(F-27).\x20Not\x20a\x20wrong-network\x20problem.','error_code':'wip_host_unreachable','retryable':!![],'recovery_hint':'Retry\x20after\x20the\x20host\x20recovers\x20(transient\x20outage),\x20or\x20have\x20the\x20merchant\x20redeploy\x20'+'the\x20.wip\x20file\x20to\x20another\x20public\x20endpoint\x20and\x20update\x20sale.wip\x20+\x20wip_hash.\x20'+'Do\x20NOT\x20switch\x20networks.','related_object':o},'message':'WIP\x20host\x20unreachable\x20—\x20order\x20not\x20created.\x20See\x20recovery_hint.'}};}return null;}catch{return null;}}export async function gateOrderNewFundCoverage(a,b){const c=a?.['order_new']?.['buy'];if(!c)return null;const d=parseTotalPayRaw(c);if(d===undefined)return null;if(d<=0x0n)return null;const e=a?.['object'];if(typeof e!=='string'||e['length']===0x0)return null;try{const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return null;const g=await query_serviceContext({'service':f,'network':b}),h=g?.['service'];if(!h)return null;const i=q=>{if(typeof q==='number'&&Number['isFinite'](q)&&q>=0x0)return BigInt(Math['trunc'](q));if(typeof q==='string'&&/^\d+$/['test'](q['trim']()))return BigInt(q['trim']());if(typeof q==='object'&&q!==null){const r=q?.['balance'];if(typeof r==='string'&&/^\d+$/['test'](r['trim']()))return BigInt(r['trim']());}return undefined;},j=i(h?.['compensation_fund']);if(j===undefined||j<=0x0n)return null;const k=0x3n,l=k*d;if(j>=l)return null;const m=(String(h?.['type']??h?.['type_raw']??'')['match'](/<(.+)>$/)??[])[0x1]??'',n=async q=>{try{return m?(await formatChainValue(q,m,b))['display']:q['toString']();}catch{return q['toString']();}},o=j/k,p='⛔\x20ORDER\x20NOT\x20CREATED\x20—\x20compensation\x20fund\x20cannot\x20cover\x20this\x20order\x20(no\x20money\x20moved)\x0a\x0a'+('Service\x20\x27'+e+'\x27\x20compensation_fund\x20holds\x20'+await n(j)+'\x20(raw\x20'+j+'),\x20below\x20the\x20')+('payout\x20requirement\x20for\x20THIS\x20order:\x203x\x20'+await n(d)+'\x20=\x20'+await n(l)+'\x20(raw\x20'+l+').\x20')+('At\x20the\x20current\x20fund\x20the\x20largest\x20coverable\x20order\x20amount\x20is\x20'+await n(o)+'\x20(raw\x20'+o+')\x20')+'—\x20orders\x20above\x20that\x20price\x20are\x20refused\x20here\x20until\x20the\x20fund\x20grows.\x20'+'If\x20a\x20ruling\x20awarded\x20more\x20than\x20the\x20fund,\x20settlement\x20is\x20ALL-OR-NOTHING:\x20'+'the\x20claim\x20aborts\x20with\x20code\x2027\x20'+'(E_COMPENSATION_NOT_MATCH),\x20nothing\x20is\x20paid\x20and\x20the\x20claim\x20is\x20NOT\x20consumed\x20—\x20'+'the\x20winner\x20retries\x20after\x20the\x20merchant\x20tops\x20up\x20the\x20fund.\x0a\x0a'+'Fix\x20(merchant):\x20top\x20up\x20via\x20service.compensation_fund_add\x20to\x20>=\x203x\x20this\x20order\x27s\x20amount,\x20then\x20retry.\x20'+'Alternative\x20(merchant):\x20run\x20WITHOUT\x20pool\x20protection\x20via\x20service.compensation_fund_withdraw\x20—\x20'+'allowed,\x20but\x20it\x20must\x20be\x20a\x20decision,\x20not\x20an\x20accident.';return{'content':[{'type':'text','text':p}],'structuredContent':{'result':{'type':'error','error':'Service\x20compensation_fund\x20('+j+'\x20raw)\x20is\x20below\x203x\x20this\x20order\x27s\x20amount\x20('+l+'\x20raw).\x20'+('Largest\x20coverable\x20order\x20amount\x20at\x20the\x20current\x20fund:\x20'+o+'\x20raw.\x20')+'Settlement\x20is\x20all-or-nothing:\x20an\x20award\x20above\x20the\x20fund\x20aborts\x20the\x20claim\x20(code\x2027),\x20nothing\x20is\x20paid;\x20a\x20zero\x20fund\x20does\x20the\x20same.','error_code':'compensation_fund_below_order_ceiling','retryable':!![],'recovery_hint':'The\x20MERCHANT\x20tops\x20up\x20via\x20service.compensation_fund_add\x20to\x20>=\x203x\x20this\x20order\x27s\x20total,\x20then\x20the\x20buyer\x20'+'retries\x20the\x20order.\x20Running\x20with\x20no\x20fund\x20at\x20all\x20is\x20allowed\x20but\x20is\x20an\x20explicit\x20choice\x20'+'(service.compensation_fund_withdraw)\x20that\x20removes\x20payout\x20protection.','related_object':f},'message':'Order\x20not\x20created:\x20the\x20Service\x27s\x20compensation\x20fund\x20cannot\x20cover\x203x\x20this\x20order\x27s\x20amount.\x20See\x20recovery_hint.'}};}catch{return null;}}export async function gateServiceBuyGuardMount(a,b){const c=a?.['buy_guard'];if(typeof c!=='string'||c['trim']()==='')return null;try{const d=c['startsWith']('0x')?c:await LocalMark['Instance']()['get_address'](c)??undefined;if(!d)return null;const e=await batchQueryObjectsByIds([d],b,!![]),f=e?.[0x0];if(!f||f?.['type']!=='Guard')return null;const g=f?.['data']??f,h=Array['isArray'](g?.['table'])?g['table']:[],i=h['some'](k=>Number(k?.['identifier'])===0x0&&k?.['b_submission']===!![]);if(!i)return null;const j='⛔\x20BUY\x20GUARD\x20NOT\x20MOUNTED\x20—\x20this\x20guard\x20can\x20never\x20pass\x20a\x20buy\x20(no\x20state\x20changed)\x0a\x0a'+('Guard\x20\x27'+c+'\x27\x20declares\x20identifier\x200\x20as\x20a\x20SUBMISSION\x20row\x20(b_submission:\x20true).\x20Identifier\x200\x20carries\x20')+'the\x20transacted\x20Order\x20address\x20by\x20protocol\x20convention,\x20and\x20at\x20buy\x20time\x20the\x20order\x20does\x20not\x20exist\x20yet\x20—\x20'+'the\x20purchase\x20verifies\x20the\x20passport\x20BEFORE\x20the\x20order\x20is\x20created,\x20and\x20guard\x20tables\x20are\x20frozen\x20before\x20'+'the\x20call.\x20Mathematically\x20NO\x20passport\x20can\x20satisfy\x20the\x20check,\x20so\x20every\x20buy\x20aborts:\x20the\x20store\x20would\x20be\x20'+'unbuyable\x20while\x20looking\x20open.\x20The\x20chain\x20refuses\x20this\x20mount\x20with\x20code\x2043;\x20this\x20check\x20'+'refuses\x20it\x20here\x20for\x20the\x20same\x20reason.\x0a\x0a'+'Fix:\x20mount\x20a\x20guard\x20that\x20does\x20NOT\x20consume\x20slot\x200.\x20Guards\x20that\x20verify\x20OTHER\x20objects\x20(supply-chain:\x20'+'the\x20buyer\x20submits\x20the\x20MAIN\x20order\x20as\x20evidence)\x20use\x20other\x20slots\x20and\x20stay\x20legal\x20—\x20check\x20the\x20guard\x27s\x20'+'table\x20(query_toolkit\x20query_type=\x27guard_panorama\x27)\x20and\x20remount\x20via\x20service.buy_guard\x20with\x20a\x20compliant\x20guard.';return{'content':[{'type':'text','text':j}],'structuredContent':{'result':{'type':'error','error':'buy_guard\x20\x27'+c+'\x27\x20declares\x20slot\x200\x20as\x20a\x20submission\x20row\x20—\x20a\x20buy\x20can\x20never\x20pass\x20it\x20'+'(slot\x200\x20=\x20the\x20transacted\x20Order\x20address,\x20which\x20does\x20not\x20exist\x20at\x20passport-verify\x20time).','error_code':'buy_guard_order_slot_mount_refused','retryable':!![],'recovery_hint':'Mount\x20a\x20guard\x20whose\x20table\x20does\x20NOT\x20declare\x20identifier\x200\x20as\x20a\x20submission\x20row\x20'+'(b_submission:\x20true).\x20Guards\x20verifying\x20other\x20objects\x20use\x20other\x20slots\x20and\x20stay\x20legal.','related_object':d},'message':'buy_guard\x20not\x20mounted:\x20the\x20guard\x20consumes\x20slot\x200\x20(the\x20transacted\x20Order\x20slot)\x20—\x20no\x20buy\x20could\x20ever\x20pass.\x20See\x20recovery_hint.'}};}catch{return null;}}export function parseTotalPayRaw(a){if(!a)return undefined;const b=c=>{if(typeof c==='string'&&/^\d+$/['test'](c['trim']()))return BigInt(c['trim']());if(typeof c==='number'&&Number['isFinite'](c)&&c>=0x0)return BigInt(Math['trunc'](c));return undefined;};if(typeof a==='object'&&a!==null&&a['total_pay']!==undefined){const c=a['total_pay'];if(typeof c==='object'&&c!==null)return b(c['balance']);return b(c);}return undefined;}export function gateOrderNewZeroTotal(a){const b=a?.['order_new']?.['buy'];if(!b)return null;const c=parseTotalPayRaw(b);if(c===undefined)return null;if(c!==0x0n)return null;const d=typeof a?.['sale']==='string'?a['sale']:undefined,e='⛔\x20ORDER\x20NOT\x20CREATED\x20—\x20the\x20on-chain\x20buy\x20refuses\x20zero-total\x20orders\x20(abort\x2042)\x0a\x0a'+'This\x20buy\x27s\x20total_pay\x20cleared\x20to\x200\x20(100%-off\x20coupon\x20/\x20zero-priced\x20sale'+(d?'\x20on\x20sale\x20\x22'+d+'\x22':'')+').\x20The\x20buy\x20entry\x20asserts\x20total\x20>\x200\x20on-chain\x20'+'(E_ZERO_TOTAL_ORDER,\x20abort\x2042)\x20and\x20rejects\x20the\x20order\x20with\x20a\x20FULL\x20rollback\x20—\x20no\x20order\x20'+'object,\x20no\x20escrow,\x20nothing\x20moves.\x20This\x20client\x20gate\x20mirrors\x20that\x20refusal\x20BEFORE\x20gas\x20is\x20spent.\x0a\x0a'+'Fix\x20(buyer):\x20keep\x20at\x20least\x201\x20raw\x20unit\x20of\x20total_pay\x20—\x20use\x20a\x20smaller\x20coupon\x20so\x20the\x20order\x20total\x20stays\x20'+'above\x20zero,\x20then\x20retry.\x0a'+'Fix\x20(merchant):\x20set\x20a\x20coupon\x20floor\x20so\x20promotions\x20cannot\x20clear\x20the\x20total\x20to\x20zero,\x20and\x20reprice\x20any\x20'+'zero-priced\x20sale\x20to\x20>=\x201\x20raw\x20unit\x20(a\x20zero-priced\x20sale\x20is\x20permanently\x20unbuyable\x20—\x20F-BS-76).\x0a'+'(allow_zero_total\x20on\x20the\x20coupon\x20is\x20disclosure-only\x20and\x20does\x20NOT\x20unlock\x20a\x20zero-total\x20buy\x20—\x20F-BS-74.)';return{'content':[{'type':'text','text':e}],'structuredContent':{'result':{'type':'error','error':'order\x20total_pay\x20is\x200:\x20the\x20on-chain\x20buy\x20entry\x20refuses\x20zero-total\x20orders\x20(E_ZERO_TOTAL_ORDER,\x20abort\x2042)\x20with\x20full\x20rollback\x20—\x20nothing\x20is\x20created\x20(F-OF2-07\x20/\x20F-azq9-44).','error_code':'order_new_zero_total_dead_order','retryable':![],'recovery_hint':'Buyer:\x20retry\x20with\x20a\x20coupon\x20that\x20leaves\x20total_pay\x20>=\x201\x20raw.\x20Merchant:\x20set\x20a\x20coupon\x20floor\x20on\x20the\x20sale\x20so\x20promotions\x20cannot\x20clear\x20the\x20total\x20to\x20zero,\x20and\x20reprice\x20zero-priced\x20sales\x20to\x20>=\x201\x20raw.','related_object':d},'message':'Order\x20not\x20created:\x20the\x20chain\x20refuses\x20zero-total\x20buys\x20(abort\x2042).\x20See\x20recovery_hint.'}};}const REFUND_TERMINAL_REGEX=/(cancel|return|withdraw|refund|exit|expired)/i;export function minCompletionFixedFloor(a,b){const c=new Map(),d=new Map(),h=[];for(const l of b){const m=String(l?.['name']??'');if(!m)continue;for(const o of Array['isArray'](l?.['pairs'])?l['pairs']:[]){const q=String(o?.['prev_node']??'');let r=c['get'](q);!r&&(r=[],c['set'](q,r));r['push'](m);if(q==='')h['push'](m);let s=d['get'](m);!s&&(s=new Set(),d['set'](m,s));for(const t of Array['isArray'](o?.['forwards'])?o['forwards']:[]){if(typeof t?.['guard']==='string'&&t['guard'])s['add'](t['guard']['toLowerCase']());}}}if(h['length']===0x0)return undefined;const i=[],j=(u,v)=>{if(i['length']>=0x100)return;if(v['includes'](u)){i['push']({'nodes':[...v,u],'cycle':!![]});return;}const w=c['get'](u)??[];if(w['length']===0x0){i['push']({'nodes':[...v,u],'cycle':![]});return;}for(const x of w)j(x,[...v,u]);};for(const u of h)j(u,[]);if(i['length']===0x0)return undefined;let k;for(const v of i){if(!v['cycle']&&REFUND_TERMINAL_REGEX['test'](v['nodes'][v['nodes']['length']-0x1]??''))continue;const w=new Set();for(const y of v['nodes']){for(const z of d['get'](y)??[])w['add'](z);}let x=0x0n;for(const A of a){if(A['guard']&&w['has'](A['guard']))x+=A['sum'];}if(k===undefined||x<k)k=x;}return k;}export function arbClaimEscrowEmptyDualPayout(a){const {orderAmount:b,escrowBalance:c,poolValue:d,acknowledged:e}=a;if(b===undefined||b<=0x0)return null;if(c!==0x0)return null;if(d!==undefined&&d<=0x0)return null;return e?'acknowledged':'refuse';}export async function gateOrderNewAmountLegCoverage(b,c){const d=b?.['order_new']?.['buy'];if(!d)return null;const e=parseTotalPayRaw(d);if(e===undefined)return null;if(e<=0x0n)return null;const f=b?.['object'];if(typeof f!=='string'||f['length']===0x0)return null;try{const g=f['startsWith']('0x')?f:await LocalMark['Instance']()['get_address'](f)??undefined;if(!g)return null;const h=await query_objects({'objects':[g],'network':c}),i=(h?.['objects']??[])['find'](o=>o?.['object']===g||o?.['type']==='Service');if(!i||i['type']!=='Service')return null;const j=i?.['order_allocators'],k=Array['isArray'](j?.['allocators'])?j['allocators']:null;if(!k)return null;const l=[];for(const o of k){const p=Array['isArray'](o?.['sharing'])?o['sharing']:[];let q=0x0n;for(const s of p){const t=typeof s?.['sharing']==='string'&&/^\d+$/['test'](s['sharing']['trim']())?BigInt(s['sharing']['trim']()):undefined;if(s?.['mode']===0x0&&t!==undefined)q+=t;}if(q>0x0n)l['push']({'guard':String(o?.['guard']??'')['toLowerCase'](),'sum':q});}if(l['length']===0x0)return null;let m;try{const u=i?.['machine']??i?.['data']?.['machine'];if(typeof u==='string'&&u['length']>0x0){const v=await fetchMachineNodes(String(u),c,![]);m=minCompletionFixedFloor(l,Array['isArray'](v)?v:[]);}}catch{m=undefined;}if(m===undefined)return null;if(e>=m)return null;const n='⛔\x20ORDER\x20NOT\x20CREATED\x20—\x20the\x20escrow\x20can\x20never\x20cover\x20this\x20Service\x27s\x20fixed\x20settlement\x20legs\x20(no\x20money\x20moved)\x0a\x0a'+('Service\x20\x27'+f+'\x27\x20order_allocators\x20carry\x20fixed-Amount\x20legs\x20totalling\x20'+m+'\x20(raw)\x20on\x20EVERY\x20')+'completion\x20route,\x20'+('but\x20THIS\x20order\x20anchors\x20only\x20'+e+'\x20(raw).\x20allocation.move\x20asserts\x20balance\x20>=\x20leg\x20at\x20every\x20')+'fixed-leg\x20fire,\x20so\x20a\x20release\x20would\x20abort\x20EINSUFFICIENT_BALANCE\x20and\x20the\x20order\x20would\x20deadlock\x20'+'mid-journey\x20with\x20money\x20already\x20escrowed.\x0a\x0a'+'Fix:\x0a'+('\x20\x20•\x20Buyer:\x20pay\x20the\x20full\x20listed\x20price\x20(order\x20amount\x20>=\x20'+m+'\x20raw)\x20—\x20partial/discounted\x20amounts\x20')+'cannot\x20complete\x20this\x20Service\x27s\x20staged\x20releases.\x0a'+'\x20\x20•\x20Merchant:\x20to\x20sell\x20at\x20a\x20lower\x20price,\x20reprice\x20the\x20SKUs\x20(sales\x20price)\x20—\x20the\x20fixed\x20legs\x20are\x20'+'immutable\x20after\x20publish\x20(order_allocators\x20append-only),\x20so\x20the\x20LEGS\x20define\x20the\x20floor,\x20not\x20the\x20sticker.';return{'content':[{'type':'text','text':n}],'structuredContent':{'result':{'type':'error','error':'Fixed-Amount\x20settlement\x20legs\x20total\x20'+m+'\x20raw\x20on\x20every\x20completion\x20route\x20but\x20the\x20order\x20anchors\x20'+e+'\x20raw\x20—\x20a\x20release\x20would\x20abort\x20EINSUFFICIENT_BALANCE\x20and\x20deadlock\x20the\x20order\x20mid-journey.','error_code':'order_below_fixed_leg_sum','retryable':!![],'recovery_hint':'Pay\x20at\x20least\x20the\x20fixed-leg\x20total,\x20or\x20have\x20the\x20merchant\x20reprice\x20the\x20SKUs.\x20The\x20legs\x20are\x20'+'immutable\x20after\x20publish\x20(order_allocators\x20append-only)\x20—\x20they\x20define\x20the\x20price\x20floor.','related_object':g},'message':'Order\x20not\x20created:\x20the\x20order\x20amount\x20is\x20below\x20the\x20Service\x27s\x20fixed\x20settlement-leg\x20total.\x20See\x20recovery_hint.'}};}catch{return null;}}const SALE_ITEM_OPS=new Set(['price_add','price_reduce','stock_add','stock_reduce','sale_suspension']);function salePriceRaw(a){const b=a?.['price']?.['balance']??a?.['price'];if(typeof b==='string'&&/^\d+$/['test'](b['trim']()))return BigInt(b['trim']());if(typeof b==='number'&&Number['isFinite'](b)&&b>=0x0)return BigInt(Math['trunc'](b));return undefined;}function saleStockRaw(a){const b=a?.['stock'];if(typeof b==='string'&&/^\d+$/['test'](b['trim']()))return BigInt(b['trim']());if(typeof b==='number'&&Number['isFinite'](b)&&b>=0x0)return BigInt(Math['trunc'](b));return undefined;}export async function prepareSaleItemOp(a,b){const c=a?.['sales']?.['op'],d=typeof c==='string'&&SALE_ITEM_OPS['has'](c)?c:a?.['restock']?.['op']==='flag'?'restock_flag':undefined;if(!d)return null;const e=d==='restock_flag'?a?.['restock']?.['sale_name']:a?.['sales']?.['sale_name'];if(typeof e!=='string'||e['length']===0x0)return null;const f=a?.['object'];if(typeof f!=='string'||f['length']===0x0)return null;try{const g=f['startsWith']('0x')?f:await LocalMark['Instance']()['get_address'](f)??undefined;if(!g)return null;const h=await query_serviceContext({'service':g,'network':b}),i=Array['isArray'](h?.['service']?.['sales'])?h['service']['sales']:[],j=i['find'](k=>typeof k?.['name']==='string'&&k['name']===e);if(!j){const k=i['map'](o=>String(o?.['name']??''))['filter'](o=>o['length']>0x0),l=e['trim']()['toLowerCase'](),m=k['find'](o=>o['trim']()['toLowerCase']()===l),n='⛔\x20SALE\x20OP\x20NOT\x20SENT\x20—\x20unknown\x20sale_name\x20(no\x20money\x20moved,\x20no\x20gas\x20spent)\x0a\x0a'+('\x22'+d+'\x22\x20names\x20sale\x20\x22'+e+'\x22,\x20which\x20does\x20NOT\x20exist\x20on\x20service\x20\x27'+f+'\x27.\x20')+'On-chain\x20this\x20op\x20would\x20abort\x20(code\x2032)\x20after\x20burning\x20gas\x20—\x20the\x20MCP\x20refuses\x20it\x20here\x20instead.\x0a\x0a'+('Available\x20sales:\x20'+(k['length']>0x0?k['map'](o=>'\x22'+o+'\x22')['join'](',\x20'):'<none>')+'\x0a')+(m?'Did\x20you\x20mean\x20\x22'+m+'\x22?\x0a':'')+'Fix:\x20copy\x20the\x20sale_name\x20EXACTLY\x20from\x20the\x20live\x20sales\x20list\x20(query_toolkit\x20/\x20service\x20context),\x20then\x20retry.';return{'block':{'content':[{'type':'text','text':n}],'structuredContent':{'result':{'type':'error','error':'sale_name\x20\x22'+e+'\x22\x20matches\x20no\x20sale\x20on\x20service\x20\x27'+f+'\x27;\x20the\x20on-chain\x20op\x20would\x20abort\x20with\x20code\x2032.\x20'+('Available\x20sales:\x20'+(k['length']>0x0?k['map'](o=>'\x22'+o+'\x22')['join'](',\x20'):'<none>')+'.')+(m?'\x20Did\x20you\x20mean\x20\x22'+m+'\x22?':''),'error_code':'sale_item_op_unknown_sale_name','retryable':!![],'recovery_hint':'Copy\x20the\x20sale_name\x20exactly\x20from\x20the\x20live\x20sales\x20list'+(m?'\x20(did\x20you\x20mean\x20\x22'+m+'\x22?)':'')+',\x20then\x20retry.','related_object':g},'message':'Sale\x20op\x20not\x20sent:\x20unknown\x20sale_name.\x20See\x20recovery_hint.'}}};}return{'prep':{'op':d,'saleName':e,'before':{'price':salePriceRaw(j),'stock':saleStockRaw(j),'suspension':typeof j?.['suspension']==='boolean'?j['suspension']:undefined,'restock':typeof j?.['restock_on_refund']==='boolean'?j['restock_on_refund']:undefined}}};}catch{return null;}}export async function prepareRestockOrderOp(a,b){if(a?.['restock']?.['op']!=='order')return null;const c=a?.['restock']?.['order'],d=a?.['object'];if(typeof c!=='string'||c['length']===0x0)return null;if(typeof d!=='string'||d['length']===0x0)return null;try{const [e,f]=await Promise['all']([d['startsWith']('0x')?Promise['resolve'](d):LocalMark['Instance']()['get_address'](d),c['startsWith']('0x')?Promise['resolve'](c):LocalMark['Instance']()['get_address'](c)]),g=normAddr(e),h=normAddr(f);if(!g||!h)return null;const i=await batchQueryObjectsByIds([h],b,!![]),j=normAddr(rootOf(i[0x0])['service']);if(i['length']>0x0&&j!==undefined&&j!==g){const l='⛔\x20RESTOCK\x20NOT\x20SENT\x20—\x20foreign\x20order\x20(no\x20money\x20moved,\x20no\x20gas\x20spent)\x0a\x0a'+('restock\x20op:\x27order\x27\x20targets\x20order\x20\x27'+c+'\x27,\x20which\x20belongs\x20to\x20service\x20')+('\x27'+j+'\x27,\x20NOT\x20\x27'+d+'\x27.\x20On-chain\x20this\x20call\x20would\x20abort\x20(code\x2026)\x20')+'after\x20burning\x20gas\x20—\x20the\x20MCP\x20refuses\x20it\x20here\x20instead.\x0a\x0a'+'Why:\x20restock\x20is\x20ownership-bound\x20—\x20only\x20an\x20order\x20of\x20THIS\x20service\x20can\x20put\x20its\x20units\x20'+'back\x20on\x20this\x20storefront\x20(a\x20merchant\x20feeding\x20any\x20visible\x20order\x20into\x20its\x20own\x20store\x20'+'would\x20inflate\x20stock).\x0a'+'Fix:\x20run\x20the\x20restock\x20against\x20the\x20order\x27s\x20OWN\x20service.';return{'content':[{'type':'text','text':l}],'structuredContent':{'result':{'type':'error','error':'order\x20\x27'+c+'\x27\x20belongs\x20to\x20service\x20\x27'+j+'\x27,\x20not\x20\x27'+d+'\x27;\x20the\x20on-chain\x20restock\x20would\x20abort\x20with\x20code\x2026.','error_code':'restock_order_foreign_service','retryable':![],'recovery_hint':'Run\x20restock\x20op:\x27order\x27\x20against\x20the\x20service\x20the\x20order\x20was\x20placed\x20on\x20(the\x20order\x27s\x20service\x20binding).','related_object':g},'message':'Restock\x20not\x20sent:\x20foreign\x20order.\x20See\x20recovery_hint.'}};}const k=await batchReadAddressKeyedFields(g,[h],b,!![]);if(k['has'](h)){const m='⛔\x20RESTOCK\x20NOT\x20SENT\x20—\x20already\x20applied\x20(no\x20money\x20moved,\x20no\x20gas\x20spent)\x0a\x0a'+('The\x20purchased\x20units\x20of\x20order\x20\x27'+c+'\x27\x20were\x20ALREADY\x20put\x20back\x20on\x20the\x20shelf\x20of\x20')+('\x27'+d+'\x27\x20—\x20restock\x20is\x20once-per-order,\x20and\x20a\x20second\x20call\x20would\x20stack\x20the\x20')+'quantity\x20again.\x20On-chain\x20this\x20call\x20would\x20abort\x20(code\x2049)\x20after\x20burning\x20gas;\x20the\x20'+'MCP\x20refuses\x20it\x20here\x20instead.\x0a\x0a'+'No\x20retry\x20will\x20succeed\x20—\x20the\x20stock\x20restoration\x20for\x20this\x20order\x20is\x20complete.\x20'+'Query\x20the\x20item\x27s\x20current\x20stock\x20to\x20confirm\x20the\x20units\x20are\x20back.';return{'content':[{'type':'text','text':m}],'structuredContent':{'result':{'type':'error','error':'order\x20\x27'+c+'\x27\x20was\x20already\x20restocked\x20on\x20\x27'+d+'\x27;\x20restock\x20is\x20once-per-order\x20and\x20the\x20on-chain\x20replay\x20would\x20abort\x20with\x20code\x2049.','error_code':'restock_order_already_applied','retryable':![],'recovery_hint':'No\x20retry\x20will\x20succeed\x20—\x20the\x20restoration\x20is\x20already\x20complete.\x20Check\x20the\x20sale\x20item\x27s\x20stock\x20to\x20confirm.','related_object':g},'message':'Restock\x20not\x20sent:\x20already\x20applied\x20for\x20this\x20order.\x20See\x20recovery_hint.'}};}return null;}catch{return null;}}export async function emitSaleItemOpReadback(a,b,c,d){try{const e=b?.['object'];if(typeof e!=='string'||e['length']===0x0)return;const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return;const g=await query_serviceContext({'service':f,'network':c}),h=Array['isArray'](g?.['service']?.['sales'])?g['service']['sales']:[],i=h['find'](p=>typeof p?.['name']==='string'&&p['name']===a['saleName']);if(!i){d['push']('SALE\x20OP\x20READ-BACK:\x20\x22'+a['op']+'\x22\x20on\x20\x22'+a['saleName']+'\x22\x20—\x20the\x20sale\x20is\x20GONE\x20from\x20the\x20live\x20list\x20after\x20the\x20tx\x20'+'(removed\x20concurrently?).\x20Verify\x20with\x20query_toolkit\x20before\x20relying\x20on\x20it.');return;}const j={'price':salePriceRaw(i),'stock':saleStockRaw(i),'suspension':typeof i?.['suspension']==='boolean'?i['suspension']:undefined,'restock':typeof i?.['restock_on_refund']==='boolean'?i['restock_on_refund']:undefined},k=a['op']==='sale_suspension'?'suspension':a['op']==='restock_flag'?'restock':a['op']['startsWith']('price')?'price':'stock',l=p=>p===undefined?'<unreadable>':p['toString'](),m=p=>p===undefined?'<unreadable>':String(p),n=k==='price'?'price:\x20'+l(a['before']['price'])+'\x20→\x20'+l(j['price'])+'\x20(raw)':k==='stock'?'stock:\x20'+l(a['before']['stock'])+'\x20→\x20'+l(j['stock'])+'\x20(units)':k==='restock'?'restock_on_refund:\x20'+m(a['before']['restock'])+'\x20→\x20'+m(j['restock']):'suspension:\x20'+m(a['before']['suspension'])+'\x20→\x20'+m(j['suspension']),o=k==='price'?a['before']['price']!==undefined&&j['price']!==undefined&&a['before']['price']!==j['price']:k==='stock'?a['before']['stock']!==undefined&&j['stock']!==undefined&&a['before']['stock']!==j['stock']:k==='restock'?a['before']['restock']!==undefined&&j['restock']!==undefined&&a['before']['restock']!==j['restock']:a['before']['suspension']!==undefined&&j['suspension']!==undefined&&a['before']['suspension']!==j['suspension'];d['push'](o?'SALE\x20OP\x20READ-BACK:\x20\x22'+a['op']+'\x22\x20landed\x20on\x20\x22'+a['saleName']+'\x22\x20—\x20'+n+'.':'SALE\x20OP\x20READ-BACK:\x20\x22'+a['op']+'\x22\x20on\x20\x22'+a['saleName']+'\x22\x20left\x20the\x20target\x20field\x20UNCHANGED\x20('+n+')\x20—\x20'+'a\x20saturated\x20stock\x20reduce\x20or\x20a\x20same-value\x20write;\x20confirm\x20this\x20is\x20intended.');}catch{}}export async function prepareSalesAddDuplicateGate(a,b,c){if(a?.['sales']?.['op']!=='add')return null;if(c?.['confirmed']===!![])return null;const d=Array['isArray'](a?.['sales']?.['sales'])?a['sales']['sales']:[];if(d['length']===0x0)return null;const e=a?.['object'];if(typeof e!=='string'||e['length']===0x0)return null;try{const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return null;const g=await query_serviceContext({'service':f,'network':b}),h=Array['isArray'](g?.['service']?.['sales'])?g['service']['sales']:[],i=new Map();for(const p of h){if(typeof p?.['name']==='string')i['set'](p['name'],p);}const j=d['filter'](q=>typeof q?.['name']==='string'&&i['has'](q['name']));if(j['length']===0x0)return null;const k=q=>{const r=q?.['balance']??q;if(typeof r==='string'&&/^\d+$/['test'](r['trim']()))return r['trim']();if(typeof r==='number'&&Number['isFinite'](r)&&r>=0x0)return String(Math['trunc'](r));return'<unset>';},l=(q,r)=>{const t=saleStockRaw(q),u=saleStockRaw({'stock':r?.['stock']});return t!==undefined&&u!==undefined&&u<t;},m=j['map'](q=>{const r=i['get'](q['name']),t=l(r,q);return'\x20\x20•\x20\x22'+q['name']+'\x22\x0a'+('\x20\x20\x20\x20\x20\x20price:\x20\x20\x20\x20\x20\x20'+k(r?.['price'])+'\x20→\x20'+k(q?.['price'])+'\x20(raw\x20units)\x0a')+('\x20\x20\x20\x20\x20\x20stock:\x20\x20\x20\x20\x20\x20'+k(r?.['stock'])+'\x20→\x20'+k(q?.['stock'])+'\x20(units)')+(t?'\x20\x20⚠️\x20STOCK\x20LOSS\x20—\x20the\x20new\x20value\x20REPLACES\x20the\x20remaining\x20inventory':'')+'\x0a'+('\x20\x20\x20\x20\x20\x20suspension:\x20'+String(r?.['suspension']??'<unset>')+'\x20→\x20'+String(q?.['suspension']??'<unset>')+'\x0a')+'\x20\x20\x20\x20\x20\x20wip/wip_hash:\x20also\x20replaced\x20by\x20the\x20incoming\x20values';}),n=j['some'](q=>l(i['get'](q['name']),q)),o='⏸\x20SALES\x20ADD\x20HELD\x20FOR\x20CONFIRMATION\x20—\x20same-name\x20overwrite\x20(nothing\x20sent\x20yet)\x0a\x0a'+('op:add\x20on\x20service\x20\x27'+e+'\x27\x20re-declares\x20'+j['length']+'\x20existing\x20product\x20name(s).\x20')+'On-chain\x20this\x20is\x20a\x20FULL\x20ROW\x20REPLACEMENT\x20(an\x20exact\x20name\x20match\x20replaces\x20the\x20entire\x20stored\x20row\x20with\x20the\x20incoming\x20sale)\x20—\x20'+'price,\x20stock,\x20suspension\x20and\x20the\x20wip\x20binding\x20all\x20take\x20the\x20NEW\x20values;\x20it\x20is\x20NOT\x20an\x20append.\x0a\x0a'+(m['join']('\x0a')+'\x0a\x0a')+(n?'⚠️\x20At\x20least\x20one\x20product\x27s\x20remaining\x20stock\x20would\x20DROP\x20—\x20buyers\x20mid-purchase\x20can\x20hit\x20an\x20abort\x20when\x20stock\x20runs\x20out.\x0a\x0a':'')+'If\x20the\x20overwrite\x20is\x20INTENDED,\x20re-send\x20the\x20SAME\x20call\x20with\x20env.confirmed=true\x20and\x20it\x20will\x20proceed\x20as\x20declared.\x0a'+'If\x20not,\x20rename\x20the\x20incoming\x20product(s)\x20or\x20use\x20the\x20per-item\x20ops\x20(price_add\x20/\x20stock_add\x20/\x20sale_suspension)\x20to\x20change\x20one\x20field.';return{'content':[{'type':'text','text':o}],'structuredContent':{'outcome':'pending_input','message':o,'result':{'type':'pending_confirmation','preview':{'operation_type':'service_sales_add','duplicates':j['map'](q=>{const r=i['get'](q['name']);return{'sale_name':q['name'],'before':{'price':k(r?.['price']),'stock':k(r?.['stock']),'suspension':r?.['suspension']},'after':{'price':k(q?.['price']),'stock':k(q?.['stock']),'suspension':q?.['suspension']},'stock_loss':l(r,q)};})},'rule_id':'sales_add_same_name_replace'},'semantic':{'intent':'service_sales_add_awaiting_confirmation','status':'pending_input','summary':'sales\x20op:add\x20would\x20OVERWRITE\x20'+j['length']+'\x20existing\x20product(s)\x20(full\x20row\x20replacement\x20incl.\x20stock).\x20NOT\x20executed.\x20Re-send\x20with\x20env.confirmed=true\x20to\x20proceed,\x20or\x20rename\x20/\x20use\x20per-item\x20ops.','next_actions':[{'action':'confirm:\x20re-send\x20the\x20SAME\x20sales\x20op:add\x20with\x20env.confirmed=true','reason':'The\x20same-name\x20overwrite\x20is\x20intended;\x20review\x20the\x20diff\x20above\x20before\x20confirming.','tool':'onchain_operations','priority':'required'},{'action':'alternative:\x20rename\x20incoming\x20products\x20or\x20use\x20per-item\x20ops\x20(price_add\x20/\x20stock_add\x20/\x20stock_reduce\x20/\x20sale_suspension)','reason':'Per-item\x20ops\x20change\x20one\x20field\x20without\x20replacing\x20the\x20row.','tool':'onchain_operations','priority':'optional'}],'warnings':n?['At\x20least\x20one\x20product\x27s\x20remaining\x20stock\x20would\x20drop\x20under\x20the\x20incoming\x20values.']:[]}}};}catch{return null;}}export function gateServicePublishPreflight(a){if(a?.['publish']!==!![])return null;const b=a?.['creation_plan'];if(b==null)return null;const c=(h,i,j)=>({'content':[{'type':'text','text':'⛔\x20SERVICE\x20NOT\x20PUBLISHED\x20—\x20'+i+'\x0a\x0a'+j}],'structuredContent':{'result':{'type':'error','error':i,'error_code':h,'retryable':!![],'recovery_hint':j},'message':'Service\x20not\x20published:\x20the\x20creation_plan\x20gate\x20rejected\x20the\x20publish.\x20See\x20recovery_hint.'}});if(typeof b!=='object'||Array['isArray'](b)||!Array['isArray'](b['steps']))return c('creation_plan_malformed','creation_plan\x20is\x20present\x20but\x20malformed\x20(expected\x20the\x20merchant_guide\x20Plan\x20JSON\x20with\x20a\x20steps\x20array).','Pass\x20the\x20plan\x20object\x20EXACTLY\x20as\x20merchant_guide\x20delivered\x20it\x20(its\x20creation_plan\x20field),\x20or\x20omit\x20'+'creation_plan\x20entirely\x20to\x20publish\x20the\x20manual\x20way.\x20Do\x20not\x20hand-edit\x20the\x20plan.');const d=b,f=d['steps']['filter'](h=>h?.['op']==='publish');if(f['length']===0x0)return c('creation_plan_malformed','creation_plan\x20carries\x20no\x20publish\x20step\x20—\x20it\x20is\x20not\x20the\x20plan\x20merchant_guide\x20handed\x20out\x20for\x20this\x20build.','Pass\x20the\x20plan\x20object\x20EXACTLY\x20as\x20merchant_guide\x20delivered\x20it\x20(its\x20creation_plan\x20field),\x20or\x20omit\x20'+'creation_plan\x20entirely\x20to\x20publish\x20the\x20manual\x20way.');const g=typeof a?.['object']==='string'?a['object']:a?.['object']?.['name'];if(typeof g==='string'&&g['length']>0x0&&!g['startsWith']('0x')){const h=f['map'](i=>{const j=i?.['target']?.['$ref'],k=typeof j==='string'?d['steps']['find'](m=>m['id']===j):undefined,l=k?.['op']==='create'&&typeof k['params']?.['name']==='string'?k['params']['name']:undefined;return typeof l==='string'&&!l['startsWith']('0x')?l:undefined;})['filter'](i=>typeof i==='string'&&i['length']>0x0);if(h['length']>0x0&&!h['includes'](g))return c('creation_plan_target_mismatch','creation_plan\x27s\x20publish\x20step(s)\x20target\x20'+h['map'](i=>'\x27'+i+'\x27')['join'](',\x20')+'\x20'+('but\x20this\x20call\x20operates\x20on\x20\x27'+g+'\x27\x20—\x20the\x20plan\x20does\x20not\x20describe\x20this\x20Service.'),'Publish\x20the\x20Service\x20named\x20in\x20the\x20plan,\x20or\x20go\x20back\x20to\x20merchant_guide\x20and\x20rebuild\x20the\x20plan\x20for\x20'+'this\x20Service.\x20Never\x20attach\x20another\x20build\x27s\x20plan\x20to\x20a\x20publish\x20call.');}try{const {plan:i,audit:j}=preflightPlan(d),k=j['issues']['length']===0x0&&!j['findings']['some'](m=>m['level']==='critical'),l=[];for(const m of i['steps']){if(m['op']!=='publish')continue;for(const n of m['preflight']){if(n['status']==='fail')l['push'](m['id']+':\x20'+n['check']);}}if(!k||l['length']>0x0){const o=j['findings']['filter'](r=>r['level']==='critical'||l['some'](t=>t['endsWith'](r['rule_id'])))['slice'](0x0,0x8)['map'](r=>'\x20\x20•\x20['+r['level']+']\x20'+r['rule_id']+':\x20'+r['title']+'\x20—\x20'+r['description']+(r['mitigation']?'\x20Fix:\x20'+r['mitigation']:'')),p=j['issues']['slice'](0x0,0x5)['map'](r=>'\x20\x20•\x20['+r['code']+']'+(r['step']?'\x20(step\x20'+r['step']+')':'')+'\x20'+r['detail']),q=(p['length']>0x0?'Structural\x20issues:\x0a'+p['join']('\x0a')+'\x0a':'')+(o['length']>0x0?'Audit\x20findings:\x0a'+o['join']('\x0a')+'\x0a':'')+(l['length']>0x0?'Failed\x20freeze\x20gates:\x20'+l['join'](';\x20')+'.':'');return c('creation_plan_preflight_failed','the\x20creation_plan\x20freeze\x20matrix\x20has\x20failed\x20gates\x20—\x20publishing\x20it\x20would\x20go\x20live\x20against\x20a\x20plan\x20'+'merchant_guide\x27s\x20audit\x20rejected:\x0a'+q,'Fix\x20the\x20plan\x20and\x20re-run\x20merchant_guide\x20(the\x20audit\x20findings\x20above\x20name\x20the\x20rule\x20and\x20the\x20fix),\x20'+'then\x20pass\x20the\x20NEW\x20plan\x20back\x20here.\x20Do\x20not\x20publish\x20with\x20failed\x20gates:\x20order_allocators\x20and\x20the\x20'+'machine\x20binding\x20are\x20immutable\x20after\x20publish.');}return null;}catch(r){return c('creation_plan_malformed','creation_plan\x20could\x20not\x20be\x20audited\x20('+(r['message']??String(r))+').','Pass\x20the\x20plan\x20object\x20EXACTLY\x20as\x20merchant_guide\x20delivered\x20it,\x20or\x20omit\x20creation_plan\x20entirely\x20to\x20'+'publish\x20the\x20manual\x20way.');}}async function applyInitialForwardAfterOrderNew(a,b){const c=a?.['object'];if(typeof c!=='string'||c['length']===0x0)return undefined;if(b?.['dry_run']===!![])return undefined;try{const d=c['startsWith']('0x')?c:await LocalMark['Instance']()['get_address'](c)??undefined;if(!d)return undefined;const g=await query_objects({'objects':[d],'network':b?.['network'],'no_cache':!![]}),h=g?.['objects']?.[0x0]?.['data']??g?.['objects']?.[0x0],i=typeof h?.['progress']==='string'?h['progress']:undefined;if(!i)return undefined;const j=await query_objects({'objects':[i],'network':b?.['network'],'no_cache':!![]}),k=j?.['objects']?.[0x0]?.['data']??j?.['objects']?.[0x0],l=typeof k?.['machine']==='string'?k['machine']:undefined;if(!l)return undefined;const m=await fetchMachineNodes(l,b?.['network'],![]),o=[];for(const u of m){for(const v of u['pairs']){if(v['prev_node']!=='')continue;for(const w of v['forwards']){if(!w['name'])continue;o['push']({'forward':w,'target':u['name'],'threshold':v['threshold']});}}}if(o['length']===0x0)return undefined;const r=o['map'](x=>'\x22'+x['forward']['name']+'\x22\x20→\x20\x22'+x['target']+'\x22'+(x['forward']['guard']?'\x20[guarded]':''))['join'](';\x20'),s='onchain_operations\x20{\x20operation_type:\x20\x27progress\x27,\x20data:\x20{\x20object:\x20\x27'+i+'\x27,\x20'+('task:\x20\x27'+d+'\x27,\x20operate:\x20{\x20op:\x20\x27next\x27,\x20operation:\x20{\x20forward:\x20\x27<entry\x20forward>\x27,\x20')+'next_node_name:\x20\x27<target>\x27\x20}\x20}\x20}\x20}',t=o['length']===0x1&&!o[0x0]['forward']['guard']&&o[0x0]['forward']['namedOperator']===''&&o[0x0]['forward']['weight']>=o[0x0]['threshold'];if(t){const x=new CallProgress({'object':i,'task':d,'operate':{'op':'next','operation':{'forward':o[0x0]['forward']['name'],'next_node_name':o[0x0]['target']}}}),y=await x['call'](b),z=!!y&&typeof y==='object'&&y?.['effects']?.['status']?.['status']==='success';if(z)return'INITIAL\x20FORWARD\x20AUTO-APPLIED:\x20\x22'+o[0x0]['forward']['name']+'\x22\x20→\x20\x22'+o[0x0]['target']+'\x22\x20'+('(digest\x20'+(y?.['digest']??'n/a')+').\x20The\x20order\x20is\x20OPEN\x20for\x20business\x20—\x20the\x20')+'workflow\x20has\x20started,\x20counterparties\x20can\x20see\x20and\x20act\x20on\x20it\x20now.';const A=y&&typeof y==='object'?String(y?.['effects']?.['status']?.['error']??y?.['error']??'unknown\x20rejection'):'unknown\x20rejection';return'PENDING\x20INITIAL\x20FORWARD\x20(auto-apply\x20was\x20REJECTED,\x20funds\x20are\x20SAFE):\x20the\x20order\x20is\x20funded\x20but\x20'+('still\x20at\x20the\x20empty\x20entry\x20state\x20—\x20the\x20workflow\x20has\x20NOT\x20started.\x20Entry\x20forward:\x20'+r+'.\x20')+('Rejection:\x20'+A['slice'](0x0,0x12c)+'.\x20Apply\x20it\x20manually\x20once\x20the\x20cause\x20is\x20fixed:\x20'+s);}return'PENDING\x20INITIAL\x20FORWARD:\x20the\x20order\x20is\x20funded\x20but\x20still\x20at\x20the\x20empty\x20entry\x20state\x20—\x20the\x20workflow\x20'+('has\x20NOT\x20started\x20(abnb7\x20F37).\x20Entry\x20forward(s):\x20'+r+'.\x20This\x20MCP\x20auto-applies\x20only\x20an\x20')+('unguarded\x20single-forward\x20holder\x20entry;\x20this\x20entry\x20needs\x20a\x20manual\x20call:\x20'+s);}catch(B){return'PENDING\x20INITIAL\x20FORWARD\x20(auto-apply\x20probe\x20failed:\x20'+String(B?.['message']??B)['slice'](0x0,0xc8)+'):\x20the\x20'+'order\x20may\x20still\x20be\x20at\x20the\x20empty\x20entry\x20state\x20—\x20check\x20the\x20Progress\x27s\x20current\x20node\x20and\x20apply\x20the\x20'+'entry\x20forward\x20if\x20the\x20workflow\x20has\x20not\x20started\x20(query\x20the\x20order,\x20then\x20progress\x20operate\x20\x27next\x27).';}}async function snapshotProgressNodePreAdvance(a,b){try{if(b?.['dry_run']===!![])return undefined;const c=a?.['operate'];if(!c||c['op']!=='next')return undefined;const d=a?.['object'];if(typeof d!=='string'||d['length']===0x0)return undefined;const e=d['startsWith']('0x')?d:await LocalMark['Instance']()['get_address'](d)??undefined;if(!e)return undefined;const f=await query_objects({'objects':[e],'network':b?.['network'],'no_cache':!![]}),g=f?.['objects']?.[0x0]?.['data']??f?.['objects']?.[0x0],h=typeof g?.['current']==='string'?g['current']:undefined;if(h===undefined)return undefined;const i=typeof g?.['machine']==='string'?g['machine']:undefined;return{'progressAddr':e,'preNode':h,'machineAddr':i};}catch{return undefined;}}async function annotateProgressAdvanceOutcome(a,b,c,d){try{if(!b||!a)return;const e=extractProgressEventNodeFromTx(c,b['progressAddr']);if(e!==undefined&&e!==b['preNode'])return;const f=async()=>{const s=await query_objects({'objects':[b['progressAddr']],'network':d?.['network'],'no_cache':!![]});return s?.['objects']?.[0x0]?.['data']??s?.['objects']?.[0x0];};let g=await f();const h=extractObjectVersionFromTx(c,b['progressAddr']);for(let s=0x0;h!==undefined&&g&&String(g?.['version']??'')!==h&&s<0x2;s++){await new Promise(t=>setTimeout(t,0x258)),g=await f();}if(!g||h!==undefined&&String(g?.['version']??'')!==h)return;const i=typeof g?.['current']==='string'?g['current']:undefined;if(i===undefined||i!==b['preNode'])return;let j='unavailable\x20(machine\x20topology\x20read\x20failed)',k;if(b['machineAddr']){const t=await fetchMachineNodes(b['machineAddr'],d?.['network'],![]),u=[];for(const v of t){for(const w of v['pairs']){if(w['prev_node']!==b['preNode'])continue;if(k===undefined)k=w['threshold'];const x=w['forwards']['filter'](y=>!!y['name'])['map'](y=>'\x22'+y['name']+'\x22'+(y['guard']?'\x20[guarded]':'\x20[unguarded]'))['join'](',\x20');if(x)u['push']('→\x20\x22'+v['name']+'\x22\x20(threshold\x20'+w['threshold']+'):\x20'+x);}}if(u['length']>0x0)j=u['join'](';\x20');}const l=Array['isArray'](g?.['session'])?g['session']['slice'](-0x1)[0x0]:undefined,m=l&&Array['isArray'](l['forwards'])?l['forwards']['length']:undefined,o=typeof l?.['weights']==='number'?l['weights']:undefined,q=[];q['push']('ADVANCED:\x20false\x20—\x20the\x20transaction\x20succeeded\x20but\x20the\x20Progress\x20node\x20did\x20NOT\x20move;\x20it\x20is\x20still\x20\x22'+b['preNode']+'\x22.'),q['push']('Outgoing\x20edges\x20from\x20\x22'+b['preNode']+'\x22:\x20'+j+'.');const r=[];if(k!==undefined)r['push']('pair\x20threshold\x20'+k);if(m!==undefined)r['push'](m+'\x20forward\x20submission(s)\x20recorded\x20this\x20session\x20(COUNT,\x20not\x20weight)');if(o!==undefined)r['push']('accumulated\x20weight\x20'+o);if(r['length']>0x0)q['push']('Session:\x20'+r['join'](';\x20')+'.');q['push']('Threshold\x20not\x20met\x20—\x20more\x20submissions/weight\x20needed;\x20funds\x20and\x20state\x20unchanged.');Array['isArray'](a['content'])&&a['content']['push']({'type':'text','text':q['join']('\x20')});try{const y=a['structuredContent'];if(y&&typeof y==='object'){if(!y['semantic']||typeof y['semantic']!=='object')y['semantic']={};y['semantic']['forward_outcome']={'advanced':![],'current_node':b['preNode'],...k!==undefined?{'threshold':k}:{},...m!==undefined?{'session_submission_count':m}:{},...o!==undefined?{'accumulated_weight':o}:{}};}}catch{}}catch{}}async function verifyOrderNewLanded(a,b){const c=lastInFlightMarker('order_new',b);if(!c)return undefined;try{const d=await query_events({'type':'NewOrderEvent','order':'descending','limit':0x32,'network':a,'no_cache':!![]});for(const e of d?.['data']??[]){if(e?.['type']!=='NewOrderEvent')continue;const f=matchOrderLandedEvent(c,{'order':e['order'],'progress':e['progress'],'service':e['service'],'sender':e['sender'],'time':e['time'],'digest':e?.['id']?.['txDigest']??e?.['id']?.['tx_digest']});if(f)return f;}}catch{}return undefined;}const resolvedNameCache=new Map();export function invalidateResolvedNameCache(){resolvedNameCache['clear']();}async function resolveNamedObjectsInPlace(a){if(!a||typeof a!=='object')return;const b=['object','machine','arb','arbitration_object','permission','contact','um','required_info'],c=['objects','repositories','allocators','guards','items','entities','agents'],d=async e=>{if(typeof e!=='string')return e;const f=e['trim']();if(f===''||f['startsWith']('0x'))return e;const g=resolvedNameCache['get'](f);if(g)return g;try{const h=await LocalMark['Instance']()['get_address'](f);if(h)return resolvedNameCache['set'](f,h),h;return e;}catch{return e;}};for(const e of b){if(!(e in a))continue;a[e]=await d(a[e]);}for(const f of c){const g=a[f];if(!Array['isArray'](g))continue;for(let h=0x0;h<g['length'];h++){const j=g[h];if(j&&typeof j==='object'){for(const k of b){if(k in j)j[k]=await d(j[k]);}if(typeof j['name']==='string'&&!('type_parameter'in j)&&!('permission'in j)){const l=await d(j['name']);if(l!==j['name'])g[h]=l;}}else g[h]=await d(j);}}}async function collectArbitrationRefsForPublish(a,b){const c=a?.['arbitrations'];if(c&&typeof c==='object'&&(c['op']==='add'||c['op']==='set')&&Array['isArray'](c['objects'])&&c['objects']['length']>0x0)return c['objects'];const d=typeof a?.['object']==='string'?a['object']:undefined;if(d)try{const e=d['startsWith']('0x')?d:await LocalMark['Instance']()['get_address'](d)['catch'](()=>undefined)??undefined;if(e){const f=await resolveNetwork(b?.['network']),g=await query_objects({'objects':[e],'network':f,'no_cache':!![]}),h=g?.['objects']?.[0x0];if(h&&h['type']==='Service'){const i=h['data']??h;if(Array['isArray'](i['arbitrations']))return i['arbitrations'];}}}catch{}return[];}async function checkMachineBindingForPublish(a,b){const c=a?.['machine']??undefined,d=typeof c==='string'&&c['trim']()!==''?c['trim']():c&&typeof c==='object'&&typeof c['name']==='string'&&c['name']?c['name']:undefined,e=async h=>{const i=h['startsWith']('0x')?h:await LocalMark['Instance']()['get_address'](h)['catch'](()=>undefined)??undefined;if(!i)return undefined;const j=await resolveNetwork(b?.['network']),k=await query_objects({'objects':[i],'network':j,'no_cache':!![]}),l=k?.['objects']?.[0x0];return l?l['data']??l:undefined;};if(d){const h=await e(d)['catch'](()=>undefined);if(h&&h['bPublished']===![])return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20Machine\x20\x22'+d+'\x22\x20is\x20NOT\x20published.\x20'+'Binding\x20an\x20unpublished\x20Machine\x20into\x20a\x20Service\x20aborts\x20on-chain\x20(the\x20binding\x20requires\x20a\x20'+'published\x20machine\x20—\x20machine\x20E_NOT_PUBLISHED=2).\x20'+'Fix:\x20publish\x20the\x20Machine\x20first\x20(onchain_operations\x20machine\x20with\x20publish:true),\x20then\x20bind\x20it.'};if(!h)return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20Machine\x20\x22'+d+'\x22\x20could\x20not\x20be\x20resolved\x20on-chain.\x20'+'Check\x20the\x20name/id\x20and\x20network\x20(env.network)\x20—\x20publishing\x20locks\x20the\x20reference.'};return{'ok':!![]};}const f=a?.['object']!=null&&typeof a['object']==='object';if(f)return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20a\x20NEW\x20Service\x20cannot\x20be\x20published\x20without\x20a\x20Machine.\x20'+'On-chain\x20publish\x20itself\x20does\x20not\x20check\x20this\x20(F-004),\x20but\x20the\x20result\x20is\x20a\x20dead\x20store:\x20'+'orders\x20cannot\x20progress\x20without\x20a\x20bound\x20machine,\x20and\x20the\x20machine\x20binding\x20is\x20frozen\x20after\x20'+'publish\x20(E_ALREADY_PUBLISHED=6)\x20—\x20the\x20Service\x20can\x20never\x20take\x20an\x20order\x20and\x20can\x20never\x20be\x20fixed.\x20'+'Fix:\x20create\x20+\x20publish\x20the\x20Machine\x20first,\x20then\x20bind\x20it\x20in\x20this\x20call\x20(machine:<name_or_id>).'};const g=typeof a?.['object']==='string'?a['object']:undefined;if(g){const i=await e(g)['catch'](()=>undefined);if(i&&(i['type']===undefined||i['type']==='Service')){const j=i['machine'];if(!j)return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20Service\x20\x22'+g+'\x22\x20has\x20NO\x20Machine\x20bound\x20on-chain\x20and\x20none\x20is\x20'+'provided\x20in\x20this\x20patch.\x20The\x20machine\x20binding\x20is\x20frozen\x20after\x20publish\x20'+'(E_ALREADY_PUBLISHED=6)\x20—\x20if\x20it\x20publishes\x20now,\x20it\x20can\x20never\x20take\x20an\x20order\x20(F-004\x20dead\x20store).\x20'+'Fix:\x20create\x20+\x20publish\x20a\x20Machine,\x20then\x20bind\x20it\x20in\x20this\x20same\x20call\x20(machine:<name_or_id>).'};}}return{'ok':!![]};}export function isPassportVerifyFailure(a,b){if(/Identifier\("passport"\)/['test'](a)&&/MoveAbort\([\s\S]*,\s*7\s*\)/['test'](a))return!![];if(/::passport::/['test'](a)&&/abort code:\s*7\b/['test'](a))return!![];return b&&/abort code:\s*7\b/['test'](a);}function pickSubmissionCallForDiagnosis(a){for(const b of[a?.['submission'],a?.['info']]){if(b&&typeof b==='object'&&Array['isArray'](b['guard'])&&Array['isArray'](b['submission']))return b;}return undefined;}async function diagnoseGuardFailure(a,b){const c=pickSubmissionCallForDiagnosis(a);if(!isPassportVerifyFailure(b,c!==undefined))return undefined;if(!c)return undefined;const e=getEnvConfig(a?.['env']),f=await diagnose_passport_failure(e,c);if(f['failed_index']===null||f['failed_guard']===null)return'Guard\x20diagnosis\x20(dry-run):\x20'+f['hint'];const g='Guard\x20diagnosis\x20(dry-run):\x20the\x20first\x20failing\x20impact\x20guard\x20is\x20#'+f['failed_index']+'\x20'+('('+f['failed_guard']+').\x20'+f['hint']);try{const h=await submissionItemsForGuard(f['failed_guard'],c),i=await loadGuardJsonFromChain(f['failed_guard'],e?.['network']),j=[];if(i){const k=renderGuardLegMap(i['json']['root'],i['json']['table'],h);j['push'](...k);}if(i){const l=(h??[])['map'](o=>{const p=Number(o['identifier']);if(!Number['isInteger'](p)||p<0x0||p>0xff)return undefined;const q=i['json']['table']['find'](r=>r['identifier']===p);if(!q||q['value_type']===undefined)return undefined;return{'identifier':p,'value_type':q['value_type'],'value':o['value']};})['filter'](o=>o!==undefined),m=(c['guard']??[])['map'](o=>typeof o?.['object']==='string'&&o['object']['startsWith']('0x')?o['object']:undefined)['filter'](o=>typeof o==='string'),n=await verifyGuardFailureLegs(e,f['failed_guard'],l,m);if(n['verdict']==='pass')j['push']('On-chain\x20leg\x20evaluation\x20(production\x20evaluator):\x20this\x20guard\x20PASSES\x20with\x20the\x20supplied\x20submission\x20—\x20the\x20E_VERIFY_FAILED\x20came\x20from\x20a\x20different\x20guard\x20or\x20a\x20different\x20submission\x20state.');else n['root_logic']?j['push']('On-chain\x20leg\x20evaluation\x20(production\x20evaluator):\x20legs\x20['+n['false_legs']['join'](',\x20')+']\x20of\x20the\x20'+n['root_logic']['toUpperCase']()+'\x20root\x20are\x20FALSE.\x20'+n['hint']):j['push']('On-chain\x20leg\x20evaluation\x20(production\x20evaluator):\x20the\x20single\x20root\x20condition\x20is\x20FALSE.\x20'+n['hint']);}if(j['length']>0x0)return g+'\x0a'+j['join']('\x0a');}catch{}return g;}async function submissionItemsForGuard(a,b){for(const c of Array['isArray'](b['submission'])?b['submission']:[]){let d=typeof c?.['guard']==='string'?c['guard']:undefined;if(!d)continue;!d['startsWith']('0x')&&(d=await LocalMark['Instance']()['get_address'](d)['catch'](()=>undefined)??d);if(d===a&&Array['isArray'](c['submission']))return c['submission'];}return undefined;}async function autoHoldAfterClaim(a,b,c){if(typeof c!=='string'||!c)return undefined;const d=await resolveHoldableEdges({'progressRef':c,'accountName':a?.['account']??'','network':a?.['network'],'noCache':!![]});if(!d||d['edges']['length']===0x0)return undefined;const f=[],g=[],h=[];for(const i of d['edges']){const j=i['forward']+'\x20->\x20'+i['next_node'];if(!i['holdable']){h['push'](j);continue;}try{const k=new CallOrder({'object':b,'progress':{'op':'hold','operation':{'next_node_name':i['next_node'],'forward':i['forward']},'message':'arbitration\x20claimed\x20-\x20settlement\x20held\x20(E-17a)'}}),l=await k['call'](a);if(l&&typeof l==='object'&&!('error'in l))f['push'](j);else g['push'](j);}catch{g['push'](j);}}return{'held':f,'failed':g,'notHoldable':h};}export async function handleOnchainOperations(a){let b,c=[];async function h(k,l,m,p,r){const t=new Set(['service','machine','progress','repository','arbitration','contact','treasury','reward','allocation','permission','guard','personal','demand','order','proof']);if(!t['has'](m))return;if(!p||typeof p!=='object'||'error'in p)return;if(!p['digest'])return;if(r!==undefined)try{const u=collectOnChainNamedObjectRequests(r);if(u['length']>0x0){const x=await registerLocalMarksForCreatedObjects(u,ResponseData(p),m,{'getAddress':y=>LocalMark['Instance']()['get_address'](y,l),'put':y=>LocalMark['Instance']()['put'](y,l)});x['failed']['length']>0x0&&console['warn']('[nameRegistration]\x20'+x['failed']['length']+'\x20name(s)\x20could\x20not\x20be\x20registered\x20locally:\x20'+x['failed']['map'](y=>y['name']+'\x20('+y['error']+')')['join'](',\x20'));}}catch{}try{const y=operationPrimaryType(m),z=y?ResponseData(p)['find'](A=>A['change']==='created'&&A['object']&&String(A['type'])===String(y)):undefined;if(y&&z?.['object']){const A=z['object'],[B,C]=await Promise['all']([LocalMark['Instance']()['list']({'address':A}),LocalMark['Instance']()['get_address'](autoLocalMarkName(String(y),A),l)['catch'](()=>undefined)]),D=planAutoLocalMark({'operationType':m,'created':ResponseData(p),'existingNamesForAddress':B??[],'existingAddressForName':C});D&&(await LocalMark['Instance']()['put']([{'name':D['name'],'address':D['address'],'tags':D['tags']}],l),console['warn']('[autoMark]\x20created\x20'+m+'\x20registered\x20locally\x20as\x20'+D['note']));}}catch{}if(!k)return;try{const E=ResponseData(p),F=E['filter'](G=>G['change']==='created'&&G['object']);if(k&&F['length']>0x0){const G=F['filter'](H=>typeof H['type_raw']==='string'&&H['type_raw']['includes']('::'))['map'](H=>({'type':H['type_raw']['split']('::')['pop'](),'object':H['object']}));if(G['length']>0x0){const H=await goalEngine['registerActObjects'](k,G,l??'default');H>0x0&&console['warn']('[autoRegisterResults]\x20'+H+'\x20created\x20object(s)\x20registered\x20to\x20goal\x20'+k+'\x20(ACT\x20station)');}}}catch{}}try{if(typeof a==='object'&&a!==null&&'description'in a&&!('operation_type'in a)){const B=a['description'],C=typeof B==='string'&&(B['includes']('operation_type')||B['includes']('data'));if(C)throw new Error('Invalid\x20parameter\x20structure.\x20Parameters\x20should\x20NOT\x20be\x20wrapped\x20in\x20\x27description\x27\x20field.\x0a'+'Correct\x20format:\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{...}\x20}\x0a'+'Incorrect\x20format:\x20{\x20description:\x20\x27{\x20operation_type:\x20...\x20}\x27\x20}');}b=strictParse(OnchainOperationsSchema,a,'onchain_operations\x20input');const k=getEnvConfig(b['env']);await expandBareReceiveIds(b,k?.['network']);const l=extractObjectOnlyRef(b);if(l!==undefined)return await queryObjectOnlyResult(b['operation_type'],l,k);try{const D=b['data']?.['object'];if(D&&typeof D==='object'&&D['replaceExistName']===!![]&&typeof D['name']==='string'&&D['name']['trim']()['length']>0x0){const E=await LocalMark['Instance']()['get'](D['name']['trim']());E?.['address']&&c['push']('NAME\x20REBIND:\x20local\x20name\x20\x27'+D['name']+'\x27\x20is\x20currently\x20bound\x20to\x20'+E['address']+'.\x20'+'replaceExistName=true\x20will\x20unbind\x20it\x20and\x20rebind\x20the\x20name\x20to\x20the\x20object\x20created/updated\x20by\x20this\x20'+('call\x20—\x20references\x20resolving\x20\x27'+D['name']+'\x27\x20will\x20point\x20to\x20the\x20NEW\x20object.\x20')+'If\x20this\x20is\x20unintentional,\x20drop\x20replaceExistName\x20or\x20choose\x20another\x20name.');}}catch{}if(!k['referrer']){const F=readStoredReferrer();if(F)k['referrer']=F;}if(k['network']==null)try{const G=await Config['Instance']()['network_get']();c['push']('env.network\x20not\x20set\x20—\x20routing\x20via\x20session\x20default\x20\x27'+String(G)+'\x27.\x20Pass\x20env.network\x20'+'explicitly\x20on\x20every\x20call\x20for\x20deterministic\x20routing\x20(the\x20response\x20network_source\x20echo\x20confirms\x20'+'which\x20network\x20served\x20the\x20call).');}catch{}if(k['dry_run']===!![]&&k['network']!=null)try{const H=await Config['Instance']()['network_get']();H&&H!==k['network']&&c['push']('NETWORK\x20DRIFT\x20(dry\x20run):\x20this\x20simulation\x20targets\x20\x27'+k['network']+'\x27\x20while\x20the\x20session\x20'+('default\x20is\x20\x27'+H+'\x27.\x20The\x20simulation\x20executed\x20(dry\x20runs\x20mutate\x20nothing),\x20but\x20the\x20')+('real\x20execution\x20WILL\x20land\x20on\x20\x27'+k['network']+'\x27\x20—\x20confirm\x20that\x20is\x20intended\x20before\x20dropping\x20dry_run.'));}catch{}const m=k['client_schema_version'],n=k['schema_strict_mode'],p=m?checkClientSchemaCompatibility(m,{'mode':n?'strict':'warn'}):undefined,r=(I,J,K)=>({'operation_type':b['operation_type'],'data':I,'expected':declareDispatchExpectation(b['operation_type'],I),'operation_id':stableOperationId(b['operation_type'],I),'pre_warnings':c['length']?c:undefined,'schema_check':p,'response_level':x,...J?{'evaluation':J}:{},...K?{'passport_test':K}:{}}),t=k['plan_approval'],u=k['network'],x=k['response_level'];if(k['confirmed']!==!![]&&k['dry_run']!==!![]){const I=await maybeGuardSubmissionConfirmation(b,k);if(I)return I;}delete k['confirmed'],delete k['user_intent_phrases'],delete k['client_schema_version'],delete k['response_level'],delete k['schema_strict_mode'],await resolveNamedObjectsInPlace(b['data']);const y=getSkillsHintForOnchain(b['operation_type'],b['data']);y&&c['push'](y);const z=getProjectSkillsHint();z&&c['push'](z);await assertReferencesResolve(b,k);{const J=markerOpFor(b['operation_type'],b['data']),K=b['data']!==undefined?b['data']:b,L=pendingInFlightResend(J,K,b['submission'],b['env']);if(L)return{'content':[{'type':'text','text':L}],'structuredContent':{'result':{'type':'error','error':L,'error_code':'state_conflict','retryable':!![],'recovery_hint':L}}};}switch(b['operation_type']){case'service':{const M=b['data'],N=await detectServiceGuardCircularDependency(M);if(N)return N;const O=await checkSalesWipNetworkDeployment(M,k,c);if(O)return O;const P=checkSalesZeroPrice(M);if(P)return P;const Q=describeBenchmarkIssueRisk(M?.['discount']?.['benchmark']);Q&&c['push'](Q);if(typeof M?.['discount']?.['time_ms_start']==='number'&&M['discount']['time_ms_start']>Date['now']()){const ag=Math['round']((M['discount']['time_ms_start']-Date['now']())/0xea60);c['push']('COUPON\x20NOT\x20YET\x20LIVE:\x20this\x20discount\x27s\x20window\x20opens\x20at\x20'+new Date(M['discount']['time_ms_start'])['toISOString']()+'\x20'+('(in\x20~'+ag+'\x20min).\x20Until\x20then\x20every\x20spend\x20attempt\x20aborts\x20with\x20E_DISCOUNT_TIME_INVALID\x20')+'(buy\x20dry_run\x20code\x2035)\x20even\x20though\x20the\x20coupon\x20is\x20already\x20minted\x20and\x20listed\x20as\x20usable\x20—\x20'+'do\x20NOT\x20distribute\x20it\x20to\x20recipients\x20before\x20the\x20window\x20opens.');}const R=await checkDiscountFloorBeforeIssue(M,k?.['network'],{'resolveAddress':async ah=>LocalMark['Instance']()['get_address'](ah)['catch'](()=>undefined)??undefined,'fetchObjects':async(ah,ai)=>{const aj=await query_objects({'objects':ah,'network':ai});return aj?.['objects']??[];}});if(R['block'])return{'content':[{'type':'text','text':R['block']}],'structuredContent':{'result':{'type':'error','error':R['block'],'error_code':'discount_zero_floor','retryable':![],'recovery_hint':'Lower\x20discount_value\x20so\x20the\x20cheapest\x20SKU\x20still\x20pays\x20>=\x201\x20smallest\x20unit,\x20'+'switch\x20the\x20coupon\x20to\x20RATES\x20(type\x200)\x20with\x20a\x20value\x20below\x2010000,\x20or\x20declare\x20a\x20'+'deliberate\x20free\x20product\x20with\x20allow_zero_total:\x20true.'},'message':R['block']}};R['warning']&&c['push'](R['warning']);const S=await prepareFundOperation(M,'service',k?.['network']);if(S['blockingErrors']['length']>0x0)return buildFundBlockResult(S,'service');c['push'](...S['warnings']);if(S['confirmation']){c['push'](S['confirmation']['message']);const ah=a518b(S['confirmation']);if(ah)c['push'](ah);}const T=await warnMerchantCompensationFundLow(M,k?.['network'],c);if(T)return T;const U=M?.['order_allocators'];if(U&&typeof U==='object'){const ai=Array['isArray'](U['allocators'])?U['allocators']:[];for(let aj=0x0;aj<ai['length'];aj++){const ak=ai[aj],al=Array['isArray'](ak?.['sharing'])?ak['sharing']:[];if(al['length']<=0x1)continue;const am=new Map();for(let an=0x0;an<al['length'];an++){const ao=al[an]?.['who'];let ap=typeof ao==='string'?ao:'';if(!ap){const ar=classifyRecipient(ao);if(ar?.['kind']==='entity')ap='Entity:'+ar['address'];else{if(ar?.['kind']==='signer')ap='Signer';else{if(ar?.['kind']==='submission')ap='Guard:'+ar['identifier'];else{if(ao)ap=JSON['stringify'](ao);}}}}if(!ap)continue;const aq=am['get'](ap)??0x0;am['set'](ap,aq+0x1);}for(const [as,at]of am){at>0x1&&c['push']('DUPLICATE\x20SHARING\x20ENTITY:\x20Allocator['+aj+']\x20has\x20entity\x20\x22'+as+'\x22\x20appearing\x20'+at+'\x20times\x20'+'in\x20the\x20sharing\x20array.\x20This\x20is\x20likely\x20a\x20configuration\x20error\x20—\x20each\x20entity\x20should\x20appear\x20'+('at\x20most\x20once\x20per\x20allocator.\x20Total\x20sharing:\x20'+at*0x64+'%\x20to\x20the\x20same\x20entity.\x20')+'If\x20intentional,\x20ignore\x20this\x20warning.');}}}if(U){const au=checkOrderAllocatorsPrePublish(U,c);if(au)return au;const av=await checkEntityRecipientGate(U,'service.order_allocators',c);if(av)return av;warnAmountEscrowDeadlock(U,M?.['sales'],c);}const V=b['data']?.['order_new']?.['buy']?.['items'];if(Array['isArray'](V))for(const aw of V){aw&&typeof aw==='object'&&'quantity'in aw&&!('stock'in aw)&&(aw['stock']=aw['quantity'],delete aw['quantity']);}const W=b['data']?.['order_new']?.['order_required_info'],X=typeof W==='string'?priorProofConsumptions(W):[];X['length']>0x0&&c['push']('PROOF\x20REUSE\x20(informational):\x20the\x20WTS\x20Proof\x20\x27'+W+'\x27\x20already\x20anchored\x20'+('order_required_info\x20'+X['length']+'\x20time(s)\x20earlier\x20this\x20session')+(X[0x0]?.['service']?'\x20(service:\x20'+X[0x0]['service']+')':'')+'.\x20Reuse\x20is\x20acceptable\x20and\x20privacy-preserving\x20—\x20a\x20Proof\x20records\x20the\x20contact\x20channel,\x20'+'not\x20an\x20order;\x20do\x20NOT\x20mint\x20a\x20per-order\x20proof\x20(that\x20would\x20publicly\x20link\x20orders).\x20'+'Acceptance\x20of\x20the\x20delivered\x20info\x20is\x20the\x20merchant\x27s\x20confirming\x20forward\x20on\x20this\x20order.');const Y=await checkDiscountThresholdBeforeBuy(b['data']??M,k?.['network'],{'resolveAddress':async ax=>LocalMark['Instance']()['get_address'](ax)['catch'](()=>undefined)??undefined,'fetchObjects':async(ax,ay)=>{const az=await query_objects({'objects':ax,'network':ay});return az?.['objects']??[];}});if(Y)return{'content':[{'type':'text','text':Y}],'structuredContent':{'result':{'type':'error','error':Y,'error_code':'discount_benchmark_unmet','retryable':![],'recovery_hint':'The\x20coupon\x20would\x20be\x20consumed\x20with\x20no\x20discount\x20because\x20this\x20order\x27s\x20total\x20is\x20'+'below\x20the\x20coupon\x27s\x20threshold.\x20Raise\x20the\x20order\x20total\x20above\x20the\x20threshold,\x20omit\x20'+'\x27discount\x27\x20to\x20pay\x20the\x20list\x20price\x20and\x20keep\x20the\x20coupon,\x20or\x20use\x20a\x20coupon\x20issued\x20'+'without\x20a\x20threshold.'},'message':Y}};let Z=[];if(M?.['publish']===!![]){Z=await collectArbitrationRefsForPublish(M,k);const ax=await checkArbitrationsBeforePublish(Z,k,c);if(ax)return ax;if(U){const ay=await checkRefundRecipientSatisfiability(U,k,c);if(ay)return ay;}}warnPermissionAutoCreation(b['data'],'Service',c);let a0;if(b['data']?.['order_new']){const az=await probeOrderNewWipReachability(b['data'],k?.['network']);if(az)return az;const aA=await deriveTotalPayIfOmitted(b['data'],k?.['network']);if(aA)c['push'](aA);const aB=gateOrderNewZeroTotal(b['data']);if(aB)return aB;const aC=await gateOrderNewFundCoverage(b['data'],k?.['network']);if(aC)return aC;const aD=await gateOrderNewAmountLegCoverage(b['data'],k?.['network']);if(aD)return aD;a0=beginInFlight('order_new',b['data'],k);}const a1=await prepareSaleItemOp(M,k?.['network']);if(a1&&'block'in a1)return a1['block'];const a2=await prepareRestockOrderOp(M,k?.['network']);if(a2)return a2;M?.['restock']&&c['push']('RESTOCK\x20/\x20REFUND-WINDOW\x20DISCLOSURE:\x20restock\x20puts\x20a\x20refunded\x20order\x27s\x20purchased\x20units\x20back\x20on\x20'+'shelf\x20and\x20reopens\x20that\x20stock\x20for\x20sale\x20(the\x20order\x20path\x20is\x20two-pass\x20all-or-nothing\x20and\x20'+'once-per-order).\x20If\x20this\x20Service\x27s\x20machine\x20(or\x20its\x20template)\x20has\x20NO\x20refund-terminal\x20gate\x20—\x20'+'an\x20edge/guard\x20that\x20still\x20lets\x20orders\x20reach\x20a\x20refund\x20terminal\x20state\x20—\x20orders\x20inside\x20their\x20'+'refund\x20window\x20may\x20lose\x20refund\x20eligibility\x20or\x20create\x20fund-accounting\x20ambiguity\x20once\x20the\x20'+'restocked\x20units\x20are\x20resold.\x20Before\x20relisting,\x20confirm\x20the\x20machine\x27s\x20refund\x20rail\x20remains\x20'+'reachable\x20after\x20this\x20restock.');const a3=await prepareSalesAddDuplicateGate(M,k?.['network'],k);if(a3)return a3;const a4=await gateServiceBuyGuardMount(b['data'],k?.['network']);if(a4)return a4;const {reentry_kind:a5,...a6}=b['data'],a7=new CallService(a6);let a8;try{a8=b['submission']?await a7['call_with_submission'](k,await transformSubmission(b['submission'])):await a7['call'](k);}catch(aE){const aF=aE['message']??String(aE);if(M?.['order_allocators_append']!=null&&(/allocation/i['test'](aF)&&(/MoveAbort\(.*,\s*20\s*\)/['test'](aF)||/abort code:\s*20\b/['test'](aF))||/EALLOCATORS_NOT_EXTENSION/i['test'](aF))){const aG=await describeAllocatorsNotExtensionDiff(M?.['object'],M['order_allocators_append'],k?.['network']);if(aG)throw new Error(aG+'\x0aOriginal\x20error:\x20'+aF);}if((M?.['order_new']?.['buy']?.['items']?.['length']??0x0)>0x0&&/coin not enough|E_COIN_NOT_ENOUGH|abort.*\b20\b/i['test'](aF))throw new Error('PURCHASE\x20ABORTED\x20(E_COIN_NOT_ENOUGH\x20/\x20abort\x2020):\x20the\x20payment\x20'+'total_pay\x20is\x20LESS\x20THAN\x20the\x20order\x20total.\x20On-chain\x20order\x20total\x20=\x20'+'sale.price\x20x\x20per-item\x20QUANTITY.\x20Common\x20cause:\x20the\x20inventory\x20number\x20'+'was\x20passed\x20as\x20the\x20purchase\x20quantity\x20(the\x20buy\x20item\x20field\x20is\x20the\x20'+'number\x20of\x20units\x20to\x20buy,\x20NOT\x20the\x20product\x27s\x20available\x20stock).\x20'+'Check\x20each\x20item\x27s\x20quantity\x20and\x20ensure\x20total_pay\x20>=\x20sum(price\x20x\x20quantity).\x20'+('Original\x20error:\x20'+aF));if(/not found|GetObjectExisted|resolve|LocalMark|failed to resolve/i['test'](aF)){const aH=typeof M?.['object']==='object'&&M?.['object']!==null?M['object']['permission']:undefined;throw new Error('DEPENDENCY\x20RESOLUTION\x20FAILED:\x20One\x20or\x20more\x20referenced\x20objects\x20could\x20not\x20be\x20resolved.\x0a'+('Original\x20error:\x20'+aF+'\x0a')+'Common\x20causes:\x0a'+'\x20\x201.\x20Object\x20name\x20typo\x20—\x20check\x20spelling\x20in\x20LocalMark\x0a'+'\x20\x202.\x20Object\x20not\x20yet\x20created\x20—\x20create\x20dependencies\x20first\x0a'+'\x20\x203.\x20Object\x20on\x20different\x20network\x20—\x20check\x20env.network\x0a'+('Referenced\x20objects\x20in\x20this\x20call:\x20machine='+(M?.['machine']??'<none>')+',\x20')+('buy_guard='+(M?.['buy_guard']??'<none>')+',\x20')+('permission='+(aH??'<inline/new>')+',\x20')+('arbitrations='+describeArbitrationPayload(M?.['arbitrations'])));}throw aE;}if(a0)recordInFlightOutcome(a0,a8);a1&&'prep'in a1&&a8?.['digest']&&await emitSaleItemOpReadback(a1['prep'],M,k?.['network'],c);if(M?.['discount']!=null&&a8?.['digest'])try{const aI=ResponseData(a8)['filter'](aJ=>aJ?.['change']==='created'&&typeof aJ?.['type_raw']==='string'&&aJ['type_raw']['includes']('::service::Discount')&&typeof aJ?.['object']==='string');if(aI['length']>0x0){const aJ=M['discount'],aK=aJ?.['time_ms_end']!=null?new Date(Number(aJ['time_ms_end']))['toISOString']():'n/a';if(aI['length']===0x1&&typeof aJ?.['name']==='string'&&aJ['name']['length']>0x0){const aL=aI[0x0]['object'],aM=await LocalMark['Instance']()['get_address'](aJ['name'],k['network']);!aM||aM['toLowerCase']()===aL['toLowerCase']()?(await LocalMark['Instance']()['put']([{'name':{'value':aJ['name']},'address':aL}],k['network']),c['push']('DISCOUNT\x20ISSUED:\x20coupon\x20\x22'+aJ['name']+'\x22\x20is\x20live\x20at\x20'+aL+'\x20(bound\x20to\x20this\x20service,\x20expires\x20'+aK+',\x20single-use\x20—\x20burned\x20at\x20buy).\x20Reference\x20it\x20as\x20order_new.buy.discount:\x20\x22'+aJ['name']+'\x22\x20or\x20by\x20the\x20object\x20ID.')):c['push']('DISCOUNT\x20ISSUED:\x20coupon\x20\x22'+aJ['name']+'\x22\x20is\x20live\x20at\x20'+aL+'\x20(expires\x20'+aK+',\x20single-use).\x20LocalMark\x20name\x20\x22'+aJ['name']+'\x22\x20already\x20points\x20elsewhere\x20('+aM+')\x20—\x20reference\x20the\x20coupon\x20by\x20its\x20object\x20ID\x20in\x20order_new.buy.discount.');}else c['push']('DISCOUNT\x20ISSUED:\x20'+aI['length']+'\x20coupon(s)\x20live\x20(expires\x20'+aK+',\x20single-use\x20—\x20burned\x20at\x20buy):\x20'+(''+aI['slice'](0x0,0x5)['map'](aN=>aN['object'])['join'](',\x20')+(aI['length']>0x5?',\x20...':'')+'.\x20')+'Each\x20recipient\x20holds\x20their\x20own\x20copy;\x20reference\x20one\x20by\x20its\x20object\x20ID\x20in\x20order_new.buy.discount.');}}catch(aN){c['push']('DISCOUNT\x20ISSUED:\x20the\x20transaction\x20succeeded\x20but\x20coupon\x20disclosure\x20failed:\x20'+(aN?.['message']??String(aN)));}M?.['order_new']&&typeof W==='string'&&recordProofConsumption(W,typeof M?.['object']==='string'?M['object']:undefined);const a9=M?.['object']!=null&&typeof M['object']==='object',aa=M?.['compensation_fund_add']!=null;a9&&!aa&&c['push']('Service.compensation_fund\x20balance\x20is\x200\x20—\x20no\x20refund\x20protection\x20for\x20buyers.\x20'+'If\x20buyers\x20need\x20refund\x20protection,\x20call\x20service.compensation_fund_add\x20with\x20a\x20Coin<T>\x20'+'to\x20deposit.\x20Without\x20deposit,\x20arbitration\x20rulings\x20cannot\x20withdraw\x20compensation\x20'+'from\x20this\x20Service.\x20(Note:\x20some\x20industries\x20like\x20freelance\x20do\x20not\x20require\x20this;\x20'+'the\x20evaluation\x20engine\x20will\x20check\x20industry-specific\x20requirements.)');if(a9&&aa&&M?.['compensation_fund_add']?.['balance']!=null){const aO=M['compensation_fund_add']['balance'],aP=Array['isArray'](M?.['sales'])?M['sales']:Array['isArray'](M?.['sales']?.['sales'])?M['sales']['sales']:[],aQ=b3=>{if(typeof b3==='number'&&Number['isFinite'](b3))return b3;if(typeof b3==='string'&&/^\d+$/['test'](b3['trim']()))return Number(b3['trim']());return undefined;},aR=b3=>typeof b3==='string'&&/^\d*\.?\d+\s*[A-Za-z]{2,10}$/['test'](b3['trim']())?Number['parseFloat'](b3['trim']()):undefined,aS=aP['map'](b3=>b3?.['price'])['filter'](b3=>b3!=null),aT=aQ(aO),aU=aR(aO),aV=aS['map'](aQ),aW=aS['map'](aR),aX=aS['length']>0x0&&aV['every'](b3=>b3!==undefined)&&aT!==undefined,aY=aS['length']>0x0&&aW['every'](b3=>b3!==undefined)&&aU!==undefined,aZ=aX?aT:aY?aU:undefined,b0=aX?aV:aY?aW:[],b1=b0['length']>0x0?Math['max'](...b0):undefined,b2=0x3;aZ!==undefined&&b1!==undefined&&b1>0x0&&aZ<b2*b1&&c['push']('COMPENSATION\x20COVERAGE\x20BELOW\x20CEILING:\x20compensation_fund\x20deposit\x20('+aZ+')\x20is\x20less\x20than\x20'+(b2+'x\x20the\x20highest\x20SKU\x20price\x20=\x20'+b2*b1+'\x20')+('(highest\x20SKU\x20price\x20itself:\x20'+b1+').\x20The\x20chain\x20caps\x20any\x20award\x20at\x20')+(b2+'x\x20the\x20order\x20amount\x20(arb.move\x20MAX_INDEMNITY_MULTIPLE,\x20enforced\x20at\x20')+'ruling\x20time),\x20so\x20a\x20ruling\x20at\x20the\x20ceiling\x20would\x20abort\x20the\x20buyer\x27s\x20payout\x20with\x20code\x2027\x20'+'(E_COMPENSATION_NOT_MATCH)\x20even\x20though\x20the\x20ruling\x20is\x20valid.\x20'+('Recommend\x20depositing\x20>=\x20'+b2+'x\x20the\x20highest\x20price\x20via\x20compensation_fund_add.\x20')+'Above\x203x\x20is\x20optional\x20(it\x20only\x20buys\x20headroom\x20for\x20several\x20CONCURRENT\x20claims\x20against\x20the\x20same\x20'+'per-Service\x20pool,\x20which\x20is\x20empty\x20of\x20any\x20on-chain\x20concurrency\x20limit).');}const ab=M?.['publish']===!![];if(ab){const b3=gateServicePublishPreflight(M);if(b3)return b3;}if(ab){const b4=new Set(['audit_compensation_fund','audit_arbitrations']),b5=auditService(M,{'network':k?.['network']})['filter'](b6=>!b4['has'](b6['rule_id']));for(const b6 of b5){const b7=b6['severity']==='error'?'[AUDIT\x20ERROR]\x20':b6['severity']==='warning'?'[AUDIT]\x20':'[INFO]\x20';c['push'](b7+b6['message']+(b6['recommendation']?'\x20—\x20'+b6['recommendation']:''));}}let ac=ab&&Z['length']>0x0;if(!ab&&!ac&&aa){const b8=await collectArbitrationRefsForPublish(M,k);ac=b8['length']>0x0;}if(ab&&!ac&&aa)throw new Error('HARD\x20PRE-CHECK\x20FAILED:\x20Cannot\x20publish\x20Service\x20with\x20compensation_fund\x20>\x200\x20but\x20no\x20Arbitration\x20bound.\x0a'+'On-chain\x20rule:\x20assert!(arbitration_count\x20>\x200,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND).\x0a'+'The\x20transaction\x20WILL\x20ABORT\x20on-chain\x20if\x20you\x20proceed.\x0a'+'Fix:\x20(1)\x20Create\x20an\x20Arbitration\x20object\x20first\x20(onchain_operations\x20with\x20operation_type=\x27arbitration\x27).\x0a'+'\x20\x20\x20\x20\x20(2)\x20Bind\x20it\x20in\x20this\x20same\x20call:\x20data.arbitrations={op:\x27add\x27,\x20objects:[<arbitration_name_or_id>]}\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20\x20(array\x20shorthand\x20data.arbitrations=[...]\x20is\x20also\x20accepted),\x20or\x20bind\x20it\x20in\x20a\x20prior\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20\x20call\x20—\x20arbitrations\x20already\x20bound\x20on\x20an\x20existing\x20Service\x20are\x20detected\x20automatically.\x0a'+'\x20\x20\x20\x20\x20(3)\x20Then\x20call\x20publish=true.\x0a'+'Note:\x20After\x20publish,\x20arbitrations\x20can\x20still\x20be\x20ADDED\x20(but\x20not\x20removed\x20without\x20pause+lock).');ab&&!ac&&!aa&&c['push']('WARNING:\x20Publishing\x20Service\x20without\x20arbitrations.\x20If\x20compensation_fund\x20was\x20'+'deposited\x20in\x20a\x20prior\x20call,\x20the\x20contract\x20WILL\x20ABORT\x20with\x20'+'E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND.\x20If\x20compensation_fund\x20is\x200,\x20'+'publish\x20will\x20succeed\x20but\x20buyers\x20have\x20no\x20dispute\x20resolution\x20path.\x20'+'Recommended:\x20bind\x20arbitrations\x20before\x20publish.');!ab&&aa&&!ac&&c['push']('WARNING:\x20Depositing\x20compensation_fund\x20on\x20a\x20Service\x20without\x20arbitrations\x20bound.\x20'+'If\x20this\x20Service\x20is\x20already\x20published,\x20arbitration\x20rulings\x20will\x20not\x20be\x20able\x20to\x20'+'withdraw\x20compensation\x20from\x20this\x20Service.\x20Recommended:\x20bind\x20arbitrations\x20first,\x20'+'then\x20deposit\x20compensation_fund.');const ad=await buildGuardSubmissionPrompt(a8,'service',{'network':k?.['network'],'signer':k?.['account'],'service_address':typeof M?.['object']==='string'?M['object']:undefined});if(ad)c['push'](ad);let ae;if(M?.['order_new']&&typeof M?.['object']==='string'&&a518c('customer_intelligence'))try{ae=await evaluateServiceFromGraph(M['object'],{'context_network':k?.['network']});}catch{}const af=handleCallResult(a8,r(M,ae));return h(t,u,b['operation_type'],a8,b['data'])['catch'](()=>{}),af;}case'machine':{if(b['data']['node']&&typeof b['data']['node']==='object'&&'json_or_markdown_file'in b['data']['node']){const bi=b['data']['node']['json_or_markdown_file'];let bj;try{const bl=resolve(bi);bj=readFileSync(bl,'utf-8');}catch(bm){throw new Error('Failed\x20to\x20read\x20file\x20\x27'+bi+'\x27:\x20'+bm['message']);}const bk=parseMachineNodesFromText(bj);if(!bk['success']){const bn=a518a(bk['errors']);throw new Error('Machine\x20node\x20validation\x20failed\x20for\x20file\x20\x27'+bi+'\x27:\x0a\x0a'+bn);}if(!bk['data'])throw new Error('No\x20nodes\x20found\x20in\x20file\x20\x27'+bi+'\x27');c['push']('json_or_markdown_file\x20mode:\x20file\x20\x27'+bi+'\x27\x20parsed\x20to\x20'+bk['data']['length']+'\x20node(s)\x20and\x20'+'mapped\x20to\x20op:\x27add\x27\x20+\x20bReplace:true\x20(complete\x20in-place\x20replacement).\x20op:\x27set\x27\x20is\x20not\x20used\x20because\x20'+'it\x20is\x20rejected\x20on\x20an\x20existing\x20Machine;\x20on\x20a\x20fresh\x20Machine\x20the\x20two\x20are\x20equivalent.'),b['data']['node']={'op':'add','nodes':bk['data'],'bReplace':!![]};if(b['data']?.['publish']===!![]){const bo=machinePublishGateViolation(bk['data']);if(bo)throw new Error('Machine\x20publish\x20pre-check\x20failed\x20for\x20file\x20\x27'+bi+'\x27:\x0a\x0a'+bo);}}const b9=b['data'],ba=await checkMachinePermissionBeforePublish(b9,k);ba&&c['push'](ba);const bb=b9?.['node']?.['nodes']??b9?.['node'];try{const bp=typeof b9?.['object']==='object'&&b9?.['object']!==null?b9['object']?.['name']:b9?.['object'];recordMachineNodeNames(bp,bb);}catch{}if(Array['isArray'](bb)){const bq=/^(dispute|disputed|arbitration|arb_|arb\.|resolve_dispute|start_arbitration|open_dispute)/i;for(const br of bb){const bs=typeof br==='object'?br?.['name']:'';typeof bs==='string'&&bq['test'](bs)&&c['push']('ARBITRATION\x20SEPARATION\x20WARNING:\x20Machine\x20node\x20\x22'+bs+'\x22\x20appears\x20to\x20be\x20an\x20arbitration-related\x20node.\x0a'+'CORE\x20PRINCIPLE:\x20A\x20merchant\x20cannot\x20handle\x20disputes\x20fairly\x20—\x20they\x20would\x20be\x20\x27both\x20player\x20and\x20referee\x27.\x0a'+'The\x20WoWok\x20smart\x20contract\x20design\x20makes\x20Arbitration\x20a\x20completely\x20separate\x20object:\x0a'+'\x20\x20-\x20Arbitration\x20has\x20its\x20own\x20Permission,\x20voting_guard,\x20usage_guard,\x20and\x20balance\x0a'+'\x20\x20-\x20Arb\x20instances\x20have\x20a\x207-state\x20lifecycle\x20managed\x20by\x20Arbitration,\x20not\x20by\x20Machine\x0a'+'\x20\x20-\x20The\x20Order\x20object\x20is\x20the\x20bridge:\x20it\x20has\x20\x27progress\x27\x20(Machine)\x20and\x20\x27dispute\x27\x20(Arb\x20list)\x20fields\x0a'+'\x20\x20-\x20When\x20Arb\x20rules,\x20the\x20Order\x20executes\x20the\x20compensation\x20—\x20the\x20ONLY\x20connection\x20to\x20the\x20business\x20flow\x0a\x0a'+'CORRECT\x20PATTERN:\x0a'+'\x20\x20-\x20Machine:\x20business\x20states\x20only\x20(ordered\x20->\x20shipped\x20->\x20delivered\x20->\x20completed)\x0a'+'\x20\x20-\x20Arbitration:\x20separate\x20object\x20with\x20its\x20own\x20Permission\x20(NOT\x20shared\x20with\x20Service)\x0a'+'\x20\x20-\x20Arb:\x207-state\x20lifecycle\x20(Principal_confirming\x20->\x20Arbitrator_confirming\x20->\x20Voting\x20->\x20Arbitrated\x20->\x20Objectionable\x20->\x20Finished\x20->\x20Withdrawn)\x0a'+'\x20\x20-\x20R-M1-11:\x20NEVER\x20name\x20nodes\x20\x27refunded\x27/\x27disputed\x27/\x27arb\x27/\x27refund\x27\x20—\x20use\x20business\x20states\x20(\x27cancelled\x27/\x27returned\x27)\x20for\x20dispute\x20OUTCOMES;\x20refunds\x20route\x20via\x20Allocator\x20triggered\x20by\x20those\x20states,\x20disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x0a\x0a'+'If\x20this\x20node\x20name\x20is\x20a\x20legitimate\x20business\x20state\x20(not\x20arbitration),\x20ignore\x20this\x20warning.');}}if(Array['isArray'](bb)){const bt=bb['map'](bu=>bu&&typeof bu==='object'&&bu['role']?bu['name']+'='+bu['role']:null)['filter'](Boolean);bt['length']>0x0&&c['push']('NODE\x20ROLES\x20(metadata):\x20'+bt['join'](',\x20')+'.\x20Roles\x20are\x20display-layer\x20semantics\x20'+'(draft/active/delivered/final/cancelled)\x20—\x20they\x20are\x20NOT\x20stored\x20on-chain\x20(nodes\x20carry\x20'+'name+pairs\x20only).\x20Consumers:\x20render\x20state\x20icons/colors\x20from\x20roles;\x20nodes\x20tagged\x20'+'\x27final\x27/\x27cancelled\x27\x20are\x20settlement\x20endpoints\x20—\x20advancing\x20to\x20them\x20should\x20trigger\x20the\x20'+'fund-release\x20reminder\x20(Allocation\x20trigger),\x20not\x20further\x20business\x20steps.');}try{let bu=Array['isArray'](bb)?bb:undefined,bv;if(!bu&&b9?.['publish']===!![]){const bw=await fetchChainAnchorContext(b9?.['object'],k);bw&&(bu=bw['nodes'],bv=bw['profiles']);}if(!bb&&b9?.['publish']===!![]&&bu){const bx=machinePublishGateViolation(bu);bx&&c['push']('PUBLISH\x20GATE\x20(on-chain\x20publish\x20check):\x20'+bx);}if(bu){const by=checkGuardAnchorReachability(bu,bv),bz=formatGuardAnchorWarnings(by);if(bz)c['push'](bz);}}catch{}warnPermissionAutoCreation(b['data'],'Machine',c);const {reentry_kind:bc,...bd}=b['data'],be=new CallMachine(bd),bf=b['submission']?await be['call_with_submission'](k,await transformSubmission(b['submission'])):await be['call'](k),bg=await buildGuardSubmissionPrompt(bf,'machine',{'network':k?.['network'],'signer':k?.['account'],'machine_address':b['data']?.['object']});if(bg)c['push'](bg);const bh=handleCallResult(bf,r(b['data']));return h(t,u,b['operation_type'],bf,b['data'])['catch'](()=>{}),bh;}case'progress':{if(b['data']?.['operate']){c['push']('Progress\x20routing\x20fact:\x20on\x20an\x20order-bound\x20Progress\x20this\x20operate\x20call\x20'+'auto-routes\x20to\x20the\x20order-bound\x20path,\x20so\x20namedOperator=\x22\x22\x20(order\x20payer)\x20'+'forwards\x20execute\x20here\x20directly\x20—\x20switching\x20to\x20order.progress\x20is\x20NOT\x20required.\x20'+'If\x20this\x20Progress\x20is\x20standalone\x20(no\x20task\x20binding),\x20namedOperator=\x22\x22\x20forwards\x20'+'cannot\x20be\x20advanced\x20by\x20anyone\x20(no\x20order\x20payer\x20exists);\x20use\x20a\x20non-empty\x20'+'namedOperator\x20or\x20a\x20permissionIndex\x20forward\x20instead.');const bG=String(b['data']?.['operate']?.['operation']?.['forward']??'');/review/i['test'](bG)&&!b['data']?.['operate']?.['message']&&c['push']('Review-forward\x20hint:\x20the\x20real\x20exec\x20path\x20de-facto\x20requires\x20operate.message\x20for\x20Review-type\x20'+'forwards\x20(schema\x20marks\x20it\x20optional;\x20a\x20no-message\x20Review\x20failed\x20repeatedly\x20on\x20mainnet\x20until\x20the\x20'+'message\x20was\x20added).\x20Include\x20message:\x20\x27<review\x20text>\x27\x20in\x20this\x20call');const bH=bG+'\x20'+String(b['data']?.['operate']?.['operation']?.['next_node_name']??'');(/return.*(recv|receive|inspect)/i['test'](bH)||/^returned$/i['test'](String(b['data']?.['operate']?.['operation']?.['next_node_name']??'')))&&c['push']('NO-RESTOCK\x20reminder:\x20on-chain\x20stock\x20is\x20never\x20auto-restocked\x20—\x20a\x20return\x20only\x20moves\x20the\x20'+'Progress,\x20the\x20inventory\x20listing\x20is\x20not\x20refilled\x20automatically.\x20If\x20the\x20returned\x20goods\x20are\x20'+'resellable,\x20restock\x20the\x20sellable\x20item\x20via\x20the\x20sales\x20listing\x20before\x20relisting.');}const bA=typeof b['data']?.['review']?.['orderRef']==='string'?b['data']['review']['orderRef']:typeof b['data']?.['task']==='string'?b['data']['task']:undefined,bB=b['data']?.['review']&&b['submission']?await runReviewRepositoryWrite({'env':k,'submission':b['submission'],'review':b['data']['review'],'orderRef':bA}):[],bC=await snapshotProgressNodePreAdvance(b['data'],k),bD=new CallProgress(b['data']),bE=b['submission']?await bD['call_with_submission'](k,await transformSubmission(b['submission'])):await bD['call'](k);if(!b['submission']&&bE&&typeof bE==='object'&&'submission'in bE){const bI=bE['submission'];if(Array['isArray'](bI)&&bI['length']>0x0){const bJ=bI[0x0]?.['guard'];if(bJ){const bK={'operation':'progress_next','network':k?.['network'],'signer':k?.['account'],'progress_address':b['data']?.['object'],'order_address':b['data']?.['task']},bL=await generateGuardSubmissionPrompt(bJ,bK);bL&&c['push'](formatSubmissionPrompt(bL));}}}const bF=handleCallResult(bE,r(b['data']));bB['length']>0x0&&!(bE&&typeof bE==='object'&&'digest'in bE&&bE?.['effects']?.['status']?.['status']==='success')&&mergeReviewStepsIntoOutput(bF,bB,{'forwardOutcome':'failed\x20or\x20unconfirmed\x20—\x20the\x20pre-forward\x20review\x20write\x20MAY\x20have\x20landed\x20already\x20'+'(verify\x20via\x20the\x20repository\x20row\x20before\x20any\x20retry;\x20the\x20write\x20is\x20write-once)'});if(bE&&typeof bE==='object'&&'digest'in bE&&bE?.['effects']?.['status']?.['status']==='success'&&typeof b['data']?.['object']==='string'){const bM=b['data']?.['operate'],bN=bM?.['operation'],bO=await enrichWorkflowGuidance({'progressRef':b['data']['object'],'network':k?.['network'],'accountName':k?.['account'],'noCache':!![],'txResult':bE,'dryRun':k?.['dry_run']===!![],'compact':k?.['response_level']!=='full','operate':bN?.['forward']&&bN?.['next_node_name']?{'forward':bN['forward'],'next_node_name':bN['next_node_name'],'op':bM?.['op']}:undefined});mergeGuidanceIntoOutput(bF,bO,{'responseLevel':k?.['response_level']});}bE&&typeof bE==='object'&&'digest'in bE&&bE?.['effects']?.['status']?.['status']==='success'&&await annotateProgressAdvanceOutcome(bF,bC,bE,k);if(bE&&typeof bE==='object'&&'digest'in bE&&bE?.['effects']?.['status']?.['status']==='success'&&b['data']?.['review']){const bP={'env':k,'submission':b['submission'],'review':b['data']['review'],'orderRef':bA},bQ=b['submission']?await runReviewRewardClaim(bP):await runReviewChain(bP),bR=[...bB,...bQ];if(bR['length']>0x0)mergeReviewStepsIntoOutput(bF,bR);else{if(b['data']?.['review'])try{if(bF?.['structuredContent']&&typeof bF['structuredContent']==='object'){const bS=bF['structuredContent'];if(!bS['semantic']||typeof bS['semantic']!=='object')bS['semantic']={};bS['semantic']['warnings']=[...Array['isArray'](bS['semantic']['warnings'])?bS['semantic']['warnings']:[],'data.review\x20was\x20declared\x20but\x20produced\x20no\x20chained\x20steps\x20(missing\x20repository\x20and\x20reward_claim)\x20—\x20no\x20review\x20was\x20written\x20and\x20no\x20reward\x20was\x20claimed.'];}}catch{}}}return h(t,u,b['operation_type'],bE,b['data'])['catch'](()=>{}),bF;}case'repository':{const bT=new CallRepository(b['data']),bU=b['submission']?await bT['call_with_submission'](k,await transformSubmission(b['submission'])):await bT['call'](k),bV=await buildGuardSubmissionPrompt(bU,'repository',{'network':k?.['network'],'signer':k?.['account'],'extra':{'repository':b['data']?.['object']}});if(bV)c['push'](bV);const bW=handleCallResult(bU,r(b['data']));return h(t,u,b['operation_type'],bU,b['data'])['catch'](()=>{}),bW;}case'arbitration':{const bX=await prepareFundOperation(b['data'],'arbitration',k?.['network']);if(bX['blockingErrors']['length']>0x0)return buildFundBlockResult(bX,'arbitration');c['push'](...bX['warnings']);if(bX['confirmation']){c['push'](bX['confirmation']['message']);const c6=a518b(bX['confirmation']);if(c6)c['push'](c6);}{const c7=b['data']['voting_deadline_change'],c8=c7?.['voting_deadline'];if(typeof c8==='number'&&c8<=Date['now']())return{'content':[{'type':'text','text':'voting_deadline_change\x20refused:\x20the\x20requested\x20deadline\x20is\x20not\x20in\x20the\x20future.\x20No\x20transaction\x20was\x20sent.'}],'structuredContent':{'result':{'type':'error','error':'voting_deadline\x20'+c8+'\x20is\x20<=\x20now\x20('+Date['now']()+').','error_code':'invalid_parameter','retryable':![],'recovery_hint':'Set\x20voting_deadline_change.voting_deadline\x20to\x20an\x20ms-epoch\x20timestamp\x20STRICTLY\x20in\x20the\x20future\x20and\x20resubmit.\x20Moving\x20the\x20deadline\x20into\x20the\x20past\x20is\x20refused\x20client-side:\x20it\x20would\x20silently\x20revoke\x20every\x20other\x20arbitrator\x27s\x20remaining\x20vote\x20window\x20(instant-sovereignty\x20loophole).'},'message':'voting_deadline_change\x20refused\x20—\x20the\x20new\x20deadline\x20must\x20be\x20strictly\x20in\x20the\x20future.'}};}const bY=new CallArbitration(b['data']),bZ=b['submission']?await bY['call_with_submission'](k,await transformSubmission(b['submission'])):await bY['call'](k),c0=await buildGuardSubmissionPrompt(bZ,'arbitration',{'network':k?.['network'],'signer':k?.['account'],'extra':{'arbitration':b['data']?.['object']}});if(c0)c['push'](c0);const c1=b['data']?.['object'],c2=c1!==null&&typeof c1==='object';c2&&b['data']?.['pause']!==![]&&(c['push']('ARBITRATION\x20ACTIVATION\x20REQUIRED:\x20a\x20newly\x20created\x20Arbitration\x20defaults\x20to\x20bPaused=true\x20—\x20'+'dispute\x20filing\x20aborts\x20with\x20E_PAUSED\x20until\x20unpaused.\x20Issue\x20'+'{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20pause:false}}\x20before\x20binding\x20it\x20'+'to\x20a\x20Service\x20or\x20accepting\x20disputes.\x20NOTE:\x20unpausing\x20requires\x20permission\x20356\x20—\x20'+'the\x20creator\x20passes\x20this\x20check\x20as\x20the\x20new\x20Permission\x27s\x20admin\x20(admins\x20are\x20exempt\x20'+'from\x20permission\x20checks);\x20any\x20OTHER\x20operator\x20needs\x20an\x20explicit\x20356\x20grant\x20first.'),c['push']('PERMISSION\x20INITIALIZATION\x20REQUIRED:\x20a\x20freshly\x20created\x20Arbitration\x20has\x20NO\x20permission\x20'+'grants\x20(350-368\x20all\x20unassigned)\x20—\x20every\x20NON-admin\x20caller\x20aborts\x20with\x20\x27Missing\x20permission\x27\x20'+'(code\x205);\x20the\x20new\x20Permission\x27s\x20admin\x20(its\x20creator)\x20always\x20passes\x20and\x20needs\x20no\x20grants.\x20'+'OPEN\x20VOTING\x20IS\x20NOT\x20PERMISSIONLESS:\x20an\x20empty\x20voting_guard\x20means\x20every\x20358\x20(vote)\x20grantee\x20'+'votes\x20with\x20EQUAL\x20weight\x20(1\x20person\x201\x20vote)\x20—\x20vote()\x20asserts\x20358\x20unconditionally:\x20only\x20the\x20'+'arb\x27s\x20Permission\x20admin\x20(its\x20creator,\x20by\x20default)\x20and\x20explicit\x20358\x20grantees\x20can\x20vote,\x20so\x20'+'grant\x20358\x20to\x20BOTH\x20disputing\x20parties\x20and\x20every\x20intended\x20non-admin\x20voter,\x20or\x20voting\x20collapses\x20'+'to\x20admin-only\x20(the\x20arb\x20admin\x20is\x20the\x20sole\x20voter\x20AND\x20judge).\x20'+'Recommended\x20grants\x20via\x20the\x20Arbitration\x27s\x20Permission\x20object\x20(permission_index_add)\x20for\x20'+'NON-admin\x20operators:\x20356\x20(pause/unpause),\x20357\x20(fee),\x20362\x20(voting\x20deadline),\x20363\x20(reset),\x20'+'364-366\x20(withdraw/fees\x20alloc/transfer),\x20367-368\x20(owner\x20receive/UM);\x20'+'arbitrator:\x20361\x20(confirm\x20materials,\x20starts\x20voting)\x20+\x20359\x20(issue\x20ruling).'));if(c2)try{const c9=b['data'],ca=Array['isArray'](c9?.['voting_guard']?.['guards'])?c9['voting_guard']['guards']:[],cb=[];for(const ce of ca){const cf=ce?.['vote_weight']?.['FixedValue'];if(typeof cf==='number'&&Number['isFinite'](cf)&&cf>=0x0)cb['push'](cf);}const cc=cb['reduce']((cg,ch)=>cg+ch,0x0),cd=checkArbitrationVenueOrder({'unpaused_at_creation':c9?.['pause']===![]?!![]:undefined,'voting_guard_count':ca['length'],'max_weight_share':ca['length']>0x0&&cb['length']===ca['length']&&cc>0x0?Math['max'](...cb)/cc:undefined,'fee':c9?.['fee'],'has_description':typeof c9?.['description']==='string'&&c9['description']['trim']()!==''?!![]:c9?.['description']===undefined?![]:undefined})['filter'](cg=>cg['order_id']!=='V1-activation');for(const cg of cd)c['push'](cg['message']);c['push'](venueOperatingDoctrine());}catch{}const c3=b['data'],c4=c1!==null&&typeof c1==='string'&&c3?.['pause']===![];if(c4){const ch=bY['content']?.['fee'],ci=c3?.['fee']??ch,cj=ci===0x0||ci==='0'||ci==='0.0'||ci==='0WOW';ci!=null&&cj&&c['push']('FREE\x20ARBITRATION:\x20this\x20Arbitration\x20activates\x20with\x20fee\x20=\x200\x20—\x20dispute\x20filers\x20pay\x20nothing\x20'+'(any\x20coin\x20they\x20send\x20is\x20refunded\x20on\x20filing;\x20only\x20self.fee\x20is\x20escrowed\x20for\x20the\x20arbitrator).\x20'+'The\x20arbitrator\x20earns\x20no\x20per-case\x20income\x20from\x20this\x20service.\x20If\x20this\x20is\x20intentional\x20'+'(e.g.\x20a\x20free-dispute\x20commercial\x20model),\x20ignore\x20this\x20warning;\x20to\x20charge\x20per\x20case,\x20set\x20'+'a\x20fee:\x20{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20fee:<amount>}}.');}if(typeof c3?.['vote']?.['arb']==='string'&&typeof k?.['account']==='string')try{const ck=c3['vote']['arb']['startsWith']('0x')?c3['vote']['arb']:await LocalMark['Instance']()['get_address'](c3['vote']['arb'])??undefined;if(ck){const cl=await query_objects({'objects':[ck],'no_cache':!![],'network':k?.['network']}),cm=cl?.['objects']?.[0x0],cn=cm?.['data']??cm,co=Array['isArray'](cn?.['voting_guard'])?cn['voting_guard']['filter'](Boolean):[];if(co['length']===0x0){const cp=typeof cn?.['permission']==='string'?cn['permission']:undefined;if(cp){const cq=await query_objects({'objects':[cp],'no_cache':!![],'network':k?.['network']}),cr=cq?.['objects']?.[0x0],cs=cr?.['data']??cr,ct=Array['isArray'](cs?.['admin'])?cs['admin']:[];if(!ct['includes'](k['account'])){const cu=await fetchEntityPermissions(cp,k?.['network']),cv=cu['get'](k['account'])??[];!cv['includes'](0x166)&&c['push']('VOTE\x20PRE-FLIGHT:\x20account\x20'+k['account']+'\x20holds\x20NO\x20permission\x20358\x20on\x20this\x20Arbitration\x27s\x20'+'Permission\x20('+cp+'),\x20and\x20the\x20arb\x20has\x20no\x20voting_guard\x20(plain-vote\x20mode\x20asserts\x20358\x20'+'unconditionally)\x20—\x20this\x20vote\x20will\x20be\x20REFUSED\x20before\x20any\x20transaction\x20is\x20sent.\x20Remedy:\x20the\x20arb\x27s\x20'+'Permission\x20admin\x20grants\x20358\x20(permission_index_add\x20on\x20'+cp+';\x20equal-weight\x201-person-1-vote),\x20'+'or\x20the\x20voter\x20uses\x20the\x20weighted\x20path\x20vote.voting_guard=<registered\x20guard>\x20(passport-authorized,\x20no\x20358).\x20'+'NOTE:\x20if\x20a\x20transport\x20\x27fetch\x20failed\x27\x20surfaces\x20during\x20the\x20permission\x20read,\x20the\x20vote\x20was\x20NOT\x20submitted\x20—\x20'+'nothing\x20is\x20sent\x20until\x20the\x20permission\x20check\x20passes;\x20do\x20not\x20run\x20commit-state\x20verification.');}}}}}catch{}b['data']?.['arbitration']&&(c['push']('RULING\x20DOES\x20NOT\x20SETTLE\x20ESCROW:\x20this\x20ruling\x20records\x20the\x20feedback\x20+\x20indemnity\x20on\x20the\x20Arb\x20case\x20'+'object\x20ONLY\x20—\x20it\x20moves\x20no\x20funds\x20and\x20does\x20NOT\x20adjust\x20the\x20order\x27s\x20escrow\x20(the\x20Machine\x20workflow\x20'+'and\x20its\x20Allocation\x20are\x20independent\x20of\x20arbitration;\x20there\x20is\x20no\x20on-chain\x20linkage).\x20To\x20actually\x20'+'pay\x20the\x20buyer,\x20the\x20dispute\x20must\x20be\x20confirmed\x20and\x20then\x20claimed\x20via\x20'+'{operation_type:\x27order\x27,\x20data:{object:\x27<order>\x27,\x20arb_claim_compensation:{...}}}\x20—\x20the\x20indemnity\x20'+'is\x20paid\x20from\x20the\x20Service\x27s\x20merchant-prepaid\x20compensation_fund\x20(NOT\x20from\x20escrow),\x20capped\x20at\x203x\x20the\x20'+'order\x20amount,\x20and\x20it\x20does\x20NOT\x20re-split\x20the\x20allocator\x20ratios\x20(partial\x20/\x20proportional\x20refunds\x20via\x20a\x20'+'verdict\x20are\x20not\x20expressible\x20on-chain).\x20Because\x20the\x20two\x20tracks\x20are\x20independent,\x20the\x20buyer\x20can\x20still\x20'+'be\x20paid\x20the\x20FULL\x20escrow\x20AND\x20the\x20indemnity:\x20to\x20prevent\x20the\x20dual\x20payout,\x20freeze\x20the\x20settlement\x20by\x20'+'holding\x20the\x20order\x27s\x20edge\x20to\x20\x27completed\x27\x20before\x20it\x20settles\x20(hold\x20permission\x20=\x20the\x20forward\x27s\x20execute\x20'+'permission;\x20a\x20merchant-only\x20edge\x20needs\x20the\x20merchant/keeper\x20to\x20hold\x20it),\x20or\x20explicitly\x20accept\x20both\x20payouts.'),c['push']('ESCROW\x20FORENSICS\x20(refund-then-claim):\x20the\x20reverse\x20ordering\x20—\x20escrow\x20refund\x20first,\x20indemnity\x20'+'claim\x20second\x20—\x20is\x20NOT\x20on-chain\x20blocked,\x20but\x20it\x20IS\x20on-chain\x20distinguishable.\x20The\x20order-side\x20fund\x20'+'facts\x20(amount,\x20escrow\x20balance,\x20withdraw\x20history,\x20claimed_by,\x20workflow\x20node)\x20are\x20attached\x20to\x20this\x20'+'result\x20as\x20order_fund_facts,\x20and\x20to\x20every\x20query\x20of\x20this\x20Arb\x20case\x20as\x20_order_fund_facts\x20—\x20read\x20them\x20'+'before\x20finalizing\x20the\x20indemnity.\x20If\x20the\x20escrow\x20was\x20already\x20released\x20to\x20the\x20buyer\x20before\x20filing\x20'+'(positive\x20escrow_deficit\x20/\x20payout\x20entries\x20in\x20withdraw_history),\x20net\x20the\x20award\x20against\x20'+'the\x20refunded\x20principal\x20—\x20compensate\x20the\x20delta,\x20not\x20the\x20full\x20loss;\x20the\x20defendant\x20can\x20attach\x20the\x20'+'same\x20forensics\x20to\x20the\x20case\x20statement.'));const c5=handleCallResult(bZ,r(b['data']));try{const cw=!!bZ&&typeof bZ==='object'&&bZ?.['effects']?.['status']?.['status']==='success';if(cw){const cx=b['data'],cy=cx?.['vote']?.['arb']??cx?.['confirm']?.['arb']??cx?.['arbitration']?.['arb']??cx?.['reset']?.['arb']??cx?.['feedback']?.['arb']??cx?.['arb_withdraw']?.['arb']??cx?.['voting_deadline_change']?.['arb'],cz=cx?.['dispute']?.['order'];if(cy||cz){const cA=await buildOrderFundFacts({'arbRef':cy,'orderRef':cz,'network':k?.['network']});cA&&(c5['structuredContent']['order_fund_facts']=cA['structured'],c5['content']['push']({'type':'text','text':cA['text']}));}}}catch{}try{const cB=b['data'],cC=!!bZ&&typeof bZ==='object'&&bZ?.['effects']?.['status']?.['status']==='success',cD=!!(cB?.['confirm']||cB?.['vote']||cB?.['arbitration']);cC&&cD&&Array['isArray'](c5['content'])&&c5['content']['push']({'type':'text','text':'MONEY-MOVEMENT\x20CHECKLIST\x20—\x20this\x20adjudication\x20step\x20wrote\x20case\x20STATE\x20only\x20'+'(status\x20/\x20feedback\x20/\x20indemnity);\x20it\x20moved\x20NO\x20funds\x20and\x20paid\x20no\x20one:\x20no\x20wallet\x20balance\x20changed\x20'+'and\x20the\x20escrowed\x20case\x20fee\x20is\x20still\x20in\x20the\x20Arb\x20case.\x20To\x20actually\x20move\x20the\x20arbitration\x20fee,\x20'+'continue\x20in\x20order:\x20(1)\x20arb_withdraw\x20—\x20pulls\x20the\x20case\x20fee\x20into\x20the\x20Arbitration\x20(Registration)\x20'+'object\x27s\x20balance\x20pool\x20(immediately\x20from\x20state\x205\x20Finished;\x20from\x20state\x203\x20only\x20after\x20the\x2030-day\x20'+'no-objection\x20window;\x20refused\x20in\x20states\x200/1/2,\x20never\x20in\x20state\x204);\x20'+'(2)\x20fees_transfer\x20—\x20moves\x20the\x20Arbitration\x27s\x20ENTIRE\x20balance\x20pool\x20in\x20ONE\x20call\x20to\x20'+'to.allocation\x20(an\x20Allocation\x20object)\x20or\x20to.treasury\x20(a\x20Treasury\x20object),\x20single-key\x20\x27to\x27\x20'+'shape,\x20payment_index\x20required\x20(see\x20the\x20fees_transfer\x20field\x20description);\x20'+'(3)\x20treasury\x20target\x20only\x20—\x20treasury\x20receive:\x20\x22recently\x22\x20(permission\x20253)\x20intakes\x20the\x20'+'arrived\x20CoinWrapper,\x20then\x20treasury\x20withdraw\x20pays\x20out.\x20A\x20successful\x20arb_withdraw\x20with\x20no\x20'+'wallet\x20balance\x20change\x20is\x20EXPECTED\x20—\x20the\x20fee\x20sits\x20in\x20the\x20Arbitration\x20object\x27s\x20pool\x20until\x20'+'step\x20(2).\x20The\x20order-escrow\x20/\x20indemnity\x20track\x20is\x20independent\x20of\x20this\x20fee\x20track.'});}catch{}return h(t,u,b['operation_type'],bZ,b['data'])['catch'](()=>{}),c5;}case'contact':{warnPermissionAutoCreation(b['data'],'Contact',c);const cE=new CallContact(b['data']),cF=b['submission']?await cE['call_with_submission'](k,await transformSubmission(b['submission'])):await cE['call'](k),cG=await buildGuardSubmissionPrompt(cF,'contact',{'network':k?.['network'],'signer':k?.['account']});if(cG)c['push'](cG);const cH=handleCallResult(cF,r(b['data']));return h(t,u,b['operation_type'],cF,b['data'])['catch'](()=>{}),cH;}case'treasury':{const cI=await prepareFundOperation(b['data'],'treasury',k?.['network']);if(cI['blockingErrors']['length']>0x0)return buildFundBlockResult(cI,'treasury');c['push'](...cI['warnings']);if(cI['confirmation']){c['push'](cI['confirmation']['message']);const cN=a518b(cI['confirmation']);if(cN)c['push'](cN);}const cJ=new CallTreasury(b['data']),cK=b['submission']?await cJ['call_with_submission'](k,await transformSubmission(b['submission'])):await cJ['call'](k),cL=await buildGuardSubmissionPrompt(cK,'treasury',{'network':k?.['network'],'signer':k?.['account'],'extra':{'treasury':b['data']?.['object']}});if(cL)c['push'](cL);const cM=handleCallResult(cK,r(b['data']));return h(t,u,b['operation_type'],cK,b['data'])['catch'](()=>{}),cM;}case'reward':{const cO=await prepareFundOperation(b['data'],'reward',k?.['network']);if(cO['blockingErrors']['length']>0x0)return buildFundBlockResult(cO,'reward');c['push'](...cO['warnings']);if(cO['confirmation']){c['push'](cO['confirmation']['message']);const cU=a518b(cO['confirmation']);if(cU)c['push'](cU);}assertRewardRecipientSemantics(b['data']?.['guard_add']),await assertRewardReplayStamp(b['data']?.['guard_add'],k?.['network'],c);const cP=transformRewardInput(b['data']),cQ=new CallReward(cP),cR=b['submission']?await cQ['call_with_submission'](k,await transformSubmission(b['submission'])):await cQ['call'](k),cS=await buildGuardSubmissionPrompt(cR,'reward',{'network':k?.['network'],'signer':k?.['account'],'extra':{'reward':b['data']?.['object']}});if(cS)c['push'](cS);const cT=handleCallResult(cR,r(b['data']));return h(t,u,b['operation_type'],cR,b['data'])['catch'](()=>{}),cT;}case'allocation':{const cV=await prepareFundOperation(b['data'],'allocation',k?.['network']);if(cV['blockingErrors']['length']>0x0)return buildFundBlockResult(cV,'allocation');c['push'](...cV['warnings']);if(cV['confirmation']){c['push'](cV['confirmation']['message']);const d2=a518b(cV['confirmation']);if(d2)c['push'](d2);}if(b['data']?.['alloc_by_guard']&&b['submission']){const d3=new Set();for(const d4 of b['submission']['submission']||[]){for(const d5 of d4?.['submission']||[]){const d6=typeof d5?.['value']==='string'?d5['value']:'';if(/^0x[0-9a-fA-F]{64}$/['test'](d6))d3['add'](d6);}}if(d3['size']>0x0)try{const d7=(await batchQueryObjectsByIds([...d3],k?.['network'],!![]))['filter'](da=>da?.['type']==='Order'),d8=b['data']?.['acknowledge_dual_payout']===!![];let d9={'track':'unknown'};try{const da=b['data']?.['object'],db=typeof da==='string'&&da['startsWith']('0x')?da:await LocalMark['Instance']()['get_address'](da)['catch'](()=>undefined)??undefined;if(typeof db==='string'&&db['startsWith']('0x')){const dc=(await batchQueryObjectsByIds([db],k?.['network'],!![]))?.[0x0];let dd;const de=b['data']?.['alloc_by_guard'];if(typeof de==='string'&&/^0x[0-9a-fA-F]{64}$/['test'](de))dd=de;else typeof de==='string'&&(dd=await LocalMark['Instance']()['get_address'](de)['catch'](()=>undefined)??undefined);d9=classifyDualPayoutTrack(dc?.['allocators'],dd);}}catch{}for(const df of d7){if(typeof df['claimed_by']==='string'&&df['claimed_by']['startsWith']('0x')){if(!d8){if(d9['track']==='entity-directed'){c['push']('DUAL\x20PAYOUT\x20ADVISORY\x20(entity-directed\x20release):\x20Order\x20'+df['object']+'\x20already\x20received\x20arbitration\x20'+('compensation\x20(claimed_by='+df['claimed_by']+')\x20and\x20this\x20alloc_by_guard\x20releases\x20its\x20escrow\x20to\x20FIXED\x20')+('ENTITY\x20recipients\x20('+d9['recipients']['join'](',\x20')+')\x20—\x20no\x20buyer-receivable\x20leg,\x20so\x20the\x20buyer\x20')+'double-dip\x20block\x20does\x20not\x20apply.\x20Note\x20the\x20compensation\x20recipient\x20may\x20still\x20net\x20compensation\x20+\x20escrow\x20'+'(merchant\x20stacking);\x20verify\x20that\x20is\x20the\x20intended\x20commercial\x20outcome.');continue;}return{'content':[{'type':'text','text':'DUAL\x20PAYOUT\x20REFUSED\x20—\x20no\x20transaction\x20was\x20sent.\x20Order\x20'+df['object']+'\x20already\x20received\x20arbitration\x20compensation\x20(claimed_by='+df['claimed_by']+');\x20this\x20alloc_by_guard\x20would\x20ALSO\x20release\x20its\x20escrow'+(d9['track']==='order-directed'?'\x20to\x20order-directed\x20(guard-submitted)\x20recipients\x20—\x20on\x20refund\x20rails\x20that\x20is\x20the\x20buyer':'')+'\x20(refund\x20+\x20compensation\x20on\x20the\x20same\x20order).'}],'structuredContent':{'result':{'type':'error','error':'Order\x20'+df['object']+'\x20already\x20received\x20arbitration\x20compensation\x20(claimed_by='+df['claimed_by']+');\x20releasing\x20its\x20escrow\x20stacks\x20both\x20independent\x20payout\x20tracks\x20on\x20one\x20order'+(d9['track']==='order-directed'?'\x20(allocation\x20pays\x20order-directed\x20recipients)':'')+'\x20—\x20a\x20netting\x20decision\x20reserved\x20for\x20the\x20operator\x20via\x20acknowledge_dual_payout.','error_code':'dual_payout_unconfirmed','retryable':!![],'recovery_hint':'The\x20two\x20payout\x20tracks\x20are\x20independent\x20by\x20design:\x20the\x20chain\x20never\x20nets\x20them\x20and\x20the\x20escrow\x20receive\x20path\x20has\x20no\x20claimed_by\x20gate\x20—\x20but\x20if\x20this\x20service\x27s\x20rails\x20use\x20the\x20claimed_by\x20pairing\x20(refund\x20rail\x20claimed_by\x20none\x20/\x20paired\x20recover\x20rail\x20claimed_by\x20some),\x20the\x20on-chain\x20guard\x20may\x20REJECT\x20this\x20alloc\x20(guard_rejected);\x20that\x20rejection\x20IS\x20the\x20pairing\x20working,\x20and\x20the\x20escrow\x20exits\x20via\x20the\x20paired\x20rail\x20instead.\x20Re-send\x20the\x20SAME\x20call\x20with\x20acknowledge_dual_payout:true\x20ONLY\x20if\x20this\x20distribution\x20is\x20an\x20intentional\x20commercial\x20decision\x20(buyer\x20NET\x20=\x20compensation\x20+\x20escrow\x20refund).\x20If\x20this\x20is\x20a\x20plain\x20refund\x20of\x20an\x20un-awarded\x20order,\x20the\x20order\x20you\x20submitted\x20is\x20the\x20wrong\x20one\x20—\x20verify\x20the\x20order\x20address\x20before\x20retrying.'},'message':'Refused:\x20this\x20release\x20would\x20stack\x20an\x20escrow\x20refund\x20on\x20top\x20of\x20a\x20paid\x20arbitration\x20compensation.\x20Set\x20acknowledge_dual_payout:true\x20to\x20accept\x20explicitly.'}};}c['push']('DUAL\x20PAYOUT\x20ACKNOWLEDGED:\x20Order\x20'+df['object']+'\x20already\x20received\x20arbitration\x20compensation\x20'+('(claimed_by='+df['claimed_by']+')\x20and\x20this\x20call\x20ALSO\x20releases\x20its\x20escrow'+(d9['track']==='entity-directed'?'\x20to\x20fixed\x20entity\x20recipients\x20('+d9['recipients']['join'](',\x20')+')':'')+'\x20—\x20verify\x20the\x20net\x20payout\x20per\x20party\x20is\x20the\x20intended\x20commercial\x20outcome.\x20Proceeding\x20on\x20the\x20explicit\x20acknowledge_dual_payout\x20flag.'));}}}catch{}}if(b['data']?.['allocators']){const dg=await checkEntityRecipientGate(b['data']?.['allocators'],'allocation.allocators',c);if(dg)return dg;}let cW='';const cX=new CallAllocation(b['data']);b['data']?.['alloc_by_guard']&&(cW=beginInFlight('alloc_by_guard',b['data'],k,b['submission']));const cY=b['submission']?await cX['call_with_submission'](k,await transformSubmission(b['submission'])):await cX['call'](k);if(cW)recordInFlightOutcome(cW,cY);const cZ=await buildGuardSubmissionPrompt(cY,'allocation',{'network':k?.['network'],'signer':k?.['account'],'allocation_address':b['data']?.['object']});if(cZ)c['push'](cZ);const d0=b['data'];if(d0?.['alloc_by_guard']){const dh=ResponseData(cY)['filter'](di=>di?.['type']==='Payment'&&di?.['change']==='created');if(dh['length']>0x0){const di=dh['map'](dj=>dj['object'])['join'](',\x20');try{const dj=await batchQueryObjectsByIds(dh['map'](dp=>dp['object']),k?.['network'],!![]),dk=[];let dl=BigInt(0x0);const dm=[];let dn=![];for(const dp of dj){if(dp?.['type']==='Payment'&&dp?.['record']){for(const dq of dp['record']){const dr=formatRecipientLabel(dq['recipient']),ds=typeof dq['amount']==='string'?dq['amount']:String(dq['amount']),dt=BigInt(ds);dl+=dt,dk['push']('\x20\x20•\x20'+dr+':\x20'+formatMistAmount(dt));const du=classifyRecipient(dq['recipient']);if(du?.['kind']==='entity'&&k?.['account']&&du['address']['toLowerCase']()===String(k['account'])['toLowerCase']())dn=!![],dm['push']('\x20\x20•\x20'+dr+':\x20ALREADY\x20SPENDABLE\x20by\x20you\x20(caller\x20==\x20recipient,\x20auto-unwrapped\x20in\x20this\x20transaction\x20—\x20no\x20claim\x20step;\x20a\x20follow-up\x20payment\x20receive\x20will\x20correctly\x20report\x20no\x20pending\x20claim)');else{if(du?.['kind']==='submission')dm['push']('\x20\x20•\x20'+dr+':\x20the\x20ORDER\x20OWNER\x20receives\x20—\x20call\x20the\x20order\x27s\x20receive/claim\x20entry');else{if(du?.['kind']==='signer')dm['push']('\x20\x20•\x20'+dr+':\x20the\x20CALLER\x20receives\x20—\x20payment\x20receive\x20as\x20the\x20caller');else du?.['kind']==='entity'?dm['push']('\x20\x20•\x20'+dr+':\x20that\x20account\x20receives\x20—\x20payment\x20receive\x20as\x20'+formatRecipientLabel(dq['recipient'])):dm['push']('\x20\x20•\x20'+dr+':\x20query\x20the\x20Payment\x20object\x27s\x20record\x20for\x20the\x20claim\x20path');}}}dp['object']&&dk['push']('\x20\x20•\x20Payment\x20object:\x20'+dp['object']);}}if(dk['length']>0x0){dk['unshift']('DISTRIBUTION\x20DETAILS\x20(alloc_by_guard):'),dk['push']('\x20\x20─────────────────','\x20\x20•\x20Total\x20distributed:\x20'+formatMistAmount(dl));const dv=dj['some'](dw=>dw?.['type']==='Payment'&&dw?.['info']?.['for_object']);dv&&(dl===BigInt(0x0)?dk['push']('','ESCROW\x20MODE\x20(nothing\x20owed):\x20total\x20distributed\x20is\x200\x20—\x20'+'nothing\x20is\x20being\x20held\x20for\x20claiming\x20and\x20no\x20distribution\x20is\x20pending.'):(dk['push']('','ESCROW\x20MODE:\x20funds\x20are\x20held\x20in\x20the\x20Payment\x20wrapper(s)\x20above\x20'+'(Payment.for_object\x20points\x20to\x20an\x20Order)\x20—\x20claim\x20entry\x20PER\x20ROW:',...dm,'Note:\x20the\x20slot\x20number\x20shown\x20per\x20row\x20is\x20that\x20rail\x27s\x20DECLARED\x20'+'GuardIdentifier\x20(a\x20254\x20rail\x20legitimately\x20shows\x20254)\x20—\x20do\x20NOT\x20'+'infer\x20slot\x200\x20from\x20this\x20receipt.'),dn&&dk['push']('AUTO-CLAIMED:\x20at\x20least\x20one\x20row\x20had\x20caller\x20==\x20recipient\x20—\x20that\x20share\x20'+'was\x20unwrapped\x20inside\x20THIS\x20transaction\x20and\x20is\x20already\x20spendable;\x20no\x20claim\x20step\x20remains.'))),c['push'](dk['join']('\x0a'));}}catch{c['push']('alloc_by_guard\x20created\x20Payment\x20object(s)\x20['+di+'].\x20'+'Query\x20these\x20Payment\x20objects\x20to\x20see\x20the\x20distribution\x20details\x20and\x20check\x20for_object\x20for\x20escrow\x20mode.');}}else k?.['dry_run']===!![]?c['push']('DRY\x20RUN\x20(alloc_by_guard\x20'+d0['alloc_by_guard']+'):\x20simulation\x20succeeded.\x20'+'No\x20Payment\x20objects\x20exist\x20because\x20dry\x20runs\x20materialize\x20nothing\x20—\x20this\x20is\x20NOT\x20a\x20'+'\x22nothing\x20distributed\x22\x20signal.\x20Evaluate\x20the\x20sharing\x20plan\x20from\x20the\x20dry-run\x20balance\x20'+'output\x20above;\x20re-run\x20without\x20dry_run\x20to\x20execute.'):c['push']('NOTHING\x20DISTRIBUTED\x20(alloc_by_guard\x20'+d0['alloc_by_guard']+'):\x20the\x20transaction\x20'+'succeeded\x20but\x20created\x20NO\x20Payment\x20object,\x20so\x20no\x20funds\x20moved.\x20'+'The\x20guard\x20is\x20bound\x20to\x20this\x20allocation,\x20so\x20this\x20is\x20not\x20a\x20wrong-guard\x20mistake\x20—\x20the\x20'+'distribution\x20evaluated\x20to\x20zero.\x20Usual\x20causes:\x20the\x20sharing\x20plan\x20computes\x200\x20for\x20the\x20'+'remaining\x20balance,\x20the\x20pool\x20is\x20already\x20fully\x20distributed,\x20or\x20the\x20guard\x27s\x20once-slot\x20'+'was\x20already\x20consumed.\x20Do\x20NOT\x20report\x20this\x20allocation\x20as\x20executed.');}const d1=handleCallResult(cY,r(b['data']));return h(t,u,b['operation_type'],cY,b['data'])['catch'](()=>{}),d1;}case'permission':{const dw=b['operation_type'],dx=handlePermissionOperations(b['data'],k,r,c);return dx&&typeof dx==='object'&&'then'in dx&&dx['then'](dy=>{dy?.['structuredContent']?.['result']&&h(t,u,dw,dy['structuredContent']['result'],b['data'])['catch'](()=>{});})['catch'](()=>{}),dx;}case'guard':{const dy=b['data'],dz=dy['root'];if(dz?.['type']==='file'){const dE=dz,dF=resolve(dE['file_path']);let dG;try{dG=readFileSync(dF,'utf-8');}catch(dJ){throw new Error('Failed\x20to\x20read\x20Guard\x20definition\x20file\x20\x27'+dE['file_path']+'\x27:\x20'+dJ['message']);}const dH=parseGuardFile(dG,dE['format']);if(!dH['success']){const dK=formatGuardParseErrors(dH['errors']);throw new Error('Guard\x20validation\x20failed\x20for\x20file\x20\x27'+dE['file_path']+'\x27:\x0a\x0a'+dK);}const dI=dH['data'];dy['root']={'type':'node','node':dI['root']},dI['table']!==undefined&&dy['table']===undefined&&(dy['table']=dI['table']),dI['description']!==undefined&&dy['description']===undefined&&(dy['description']=dI['description']),dI['rely']!==undefined&&dy['rely']===undefined&&(dy['rely']=dI['rely']),dI['namedNew']!==undefined&&dy['namedNew']===undefined&&(dy['namedNew']=dI['namedNew']);}if(dy['root']&&typeof dy['root']==='object'){const dL=dy['root'];dL['type']==='node'&&dL['node']&&(dy['root']=dL['node']);}if(!dy['table']||dy['table']['length']===0x0)throw new Error('Guard\x20\x27table\x27\x20field\x20is\x20required\x20and\x20cannot\x20be\x20empty');if(!dy['root'])throw new Error('Guard\x20\x27root\x27\x20field\x20is\x20required');const dA=dy['table']['filter'](dM=>dM['b_submission']===![]&&Array['isArray'](dM['value'])&&dM['value']['length']===0x0);if(dA['length']>0x0)throw new Error('Guard\x20creation\x20blocked:\x20static\x20table\x20slot(s)\x20'+dA['map'](dM=>dM['identifier'])['join'](',\x20')+'\x20'+'carry\x20an\x20EMPTY\x20array\x20value.\x20Guard\x20table\x20construction\x20silently\x20DROPS\x20empty\x20vectors\x20—\x20these\x20rows\x20would\x20be\x20'+'MISSING\x20from\x20the\x20created\x20Guard\x20while\x20creation\x20still\x20succeeds.\x20Give\x20each\x20slot\x20a\x20non-empty\x20static\x20value,\x20'+'or\x20flip\x20it\x20to\x20b_submission=true\x20and\x20supply\x20the\x20value\x20at\x20Guard\x20trigger\x20time\x20'+'(protocol\x20once-slots:\x20255\x20keys\x20on\x20the\x20submitted\x20bytes,\x20254\x20on\x20the\x20chain-derived\x20object\x20key).');try{const dM=lintGuardNodeGates(parseGuardNodeGates(dy['root'],dy['table']));if(dM)c['push'](dM);}catch{}try{const dN=[],dO=dP=>{if(!dP||typeof dP!=='object')return;const dQ=dP;if(dQ['type']==='query'&&typeof dQ['query']==='number'){const dR=getGuardQueryByIdOrName(dQ['query']);dN['push']('query('+dQ['query']+')\x20->\x20\x27'+(dR?.['name']??'NOT\x20IN\x20CATALOG')+'\x27');}for(const dS of['parameters','nodes']){const dT=dQ[dS];if(Array['isArray'](dT))dT['forEach'](dO);}};dO(dy['root']),dN['length']>0x0&&c['push']('NUMERIC\x20QUERY\x20ID\x20RESOLUTION\x20(rndb58d8d\x20A2\x20—\x20verify\x20BEFORE\x20the\x20immutable\x20create):\x20'+(dN['join'](';\x20')+'.\x20A\x20numeric\x20ID\x20is\x20resolved\x20VERBATIM\x20at\x20runtime:\x20if\x20any\x20resolution\x20')+'above\x20is\x20NOT\x20the\x20field\x20you\x20intended,\x20STOP\x20and\x20rebuild\x20—\x20Guards\x20are\x20immutable,\x20and\x20a\x20'+'wrong-but-existing\x20ID\x20silently\x20checks\x20a\x20different\x20field\x20(it\x20only\x20fails\x20at\x20trigger\x20time,\x20'+'abort\x207,\x20without\x20naming\x20the\x20leg).\x20Prefer\x20the\x20NAMED\x20form\x20(e.g.\x20\x27order.amount\x27):\x20a\x20wrong\x20'+'name\x20fails\x20loudly\x20at\x20validation\x20instead\x20of\x20creating\x20a\x20mis-wired\x20Guard.');}catch{}const dB=new CallGuard(dy);let dC;try{dC=await dB['call'](k);}catch(dP){const dQ=dP instanceof Error?dP['message']:String(dP),dR=translateGuardTypeError(dQ);throw dR?new Error(dR):dP;}if(dC&&typeof dC==='object'&&'digest'in dC&&dC?.['effects']?.['status']?.['status']==='success'){try{const dS=ResponseData(dC)['filter'](dU=>dU['change']==='created'&&typeof dU['type_raw']==='string'&&dU['type_raw']['includes']('::guard::'))['map'](dU=>String(dU['object']))[0x0],dT=dy['namedNew']?.['name'];console['warn']('[ConfirmGate]\x20guard\x20created\x20—\x20name='+(dT??'<unnamed>')+(dS!==undefined?'\x20address='+dS:'')+('\x20digest='+(dC['digest']??'?')));}catch{}try{const dU=dy['root']?.['type']??'<unknown>',dV=Array['isArray'](dy['table'])?dy['table']:[],dW=dV['length'],dX=dV['filter'](e3=>e3?.['b_submission']===!![])['length'],dY=dy['rely']?.['guards'],dZ=Array['isArray'](dY)?dY['length']:0x0,e0=dy['rely']?.['logic_or']===!![]?'OR':dy['rely']?.['logic_or']===![]?'AND':'none',e1=['GUARD\x20LOGIC\x20SUMMARY:','\x20\x20•\x20root\x20type:\x20'+dU,'\x20\x20•\x20table\x20entries:\x20'+dW+'\x20('+dX+'\x20require\x20runtime\x20submission)'],e2=dV['filter'](e3=>e3?.['b_submission']===!![]);for(const e3 of e2){const e4=typeof e3?.['value_type']==='string'?e3['value_type']:String(e3?.['value_type']??'?');e1['push']('\x20\x20•\x20submission\x20slot\x20'+e3?.['identifier']+':\x20value_type='+e4+'\x20—\x20forwards\x20bound\x20to\x20this\x20Guard\x20'+('must\x20advance\x20with\x20submissions:[{identifier:'+e3?.['identifier']+',\x20value_type:\x22'+e4+'\x22}]\x20')+'(Address\x20slots:\x20pass\x20the\x20Order\x20object\x20address)');}dZ>0x0&&e1['push']('\x20\x20•\x20relies\x20on:\x20'+dZ+'\x20guard(s)\x20(mode:\x20'+e0+')');if(dy['description']){const e5=String(dy['description'])['slice'](0x0,0x50);e1['push']('\x20\x20•\x20description:\x20\x22'+e5+'\x22');}c['push'](e1['join']('\x0a'));}catch{}try{const e6=parseGuardTimeBounds(dy['root'],dy['table']);if(e6){const e7=[],e8=dy['namedNew']?.['name'];typeof e8==='string'&&e8['trim']()&&e7['push'](e8['trim']());try{const ea=ResponseData(dC)['filter'](eb=>eb['change']==='created'&&eb['object']&&typeof eb['type_raw']==='string'&&eb['type_raw']['includes']('::guard::'))['map'](eb=>String(eb['object']));e7['push'](...ea);}catch{}if(e7['length']>0x0)recordGuardTimeProfile(e7,e6);const e9=e6['upperWindowMs']!==undefined?'Clock\x20<=\x20'+e6['anchor']+'\x20+\x20'+e6['upperWindowMs']+'ms':'Clock\x20>=\x20'+e6['anchor']+'\x20+\x20'+e6['lowerOffsetMs']+'ms';c['push']('TIME\x20ANCHOR:\x20this\x20Guard\x20uses\x20'+e9+'.\x20'+(e6['anchor']==='order.time'?'order.time\x20anchor\x20=\x20ORDER\x20CREATION\x20time\x20—\x20upper\x20windows\x20on\x20POST-checkout\x20branches\x20must\x20instead\x20anchor\x20progress.current_time\x20(query\x201272,\x20OrderProgress\x20witness),\x20otherwise\x20the\x20window\x20may\x20expire\x20before\x20the\x20branch\x20is\x20reachable\x20(§5.5\x20dead\x20branch).\x20':'witness-derived\x20anchor\x20—\x20the\x20window\x20counts\x20from\x20entering\x20the\x20source\x20node\x20(serves\x20all\x20orders).\x20')+'The\x20Machine-side\x20reachability\x20check\x20will\x20cross-verify\x20when\x20these\x20Guards\x20are\x20bound\x20to\x20forwards.');}}catch{}try{const eb=ResponseData(dC)['filter'](ec=>ec['change']==='created'&&typeof ec['type_raw']==='string'&&ec['type_raw']['includes']('::guard::'))['map'](ec=>String(ec['object']));for(const ec of eb){const ed=await loadGuardJsonFromChain(ec,k?.['network']);if(!ed)continue;const ee=diffGuardSpecVsChain({'table':dy['table'],'root':dy['root'],'rely':dy['rely']},ed['json']);c['push'](ee['summary']);}}catch{}}const dD=handleCallResult(dC,r(b['data']));return h(t,u,b['operation_type'],dC,b['data'])['catch'](()=>{}),dD;}case'personal':{const ef=transformPersonalInput(b['data']),eg=new CallPersonal(ef),eh=await eg['call'](k),ei=handleCallResult(eh,r(b['data']));return h(t,u,b['operation_type'],eh,b['data'])['catch'](()=>{}),ei;}case'payment':{const ej=await prepareFundOperation(b['data'],'payment',k?.['network']);if(ej['blockingErrors']['length']>0x0)return buildFundBlockResult(ej,'payment');c['push'](...ej['warnings']);if(ej['confirmation']){c['push'](ej['confirmation']['message']);const eo=a518b(ej['confirmation']);if(eo)c['push'](eo);}const ek=b['data'];if(ek?.['receive']===!![]){const ep=typeof ek?.['object']==='string'&&ek['object']['length']>0x0;c['push']('RECEIVE\x20MODE\x20(order_claim):\x20You\x20are\x20unwrapping\x20CoinWrapper(s)\x20to\x20your\x20wallet.\x20'+'This\x20is\x20the\x20final\x20step\x20of\x20the\x20escrow\x20flow:\x0a'+'\x20\x201.\x20Allocation\x27s\x20alloc_by_guard\x20created\x20a\x20Payment\x20object\x20with\x20your\x20address\x20as\x20a\x20recipient\x0a'+'\x20\x202.\x20The\x20Payment\x27s\x20revenue\x20split\x20transferred\x20CoinWrapper(s)\x20to\x20your\x20wallet\x20(owned\x20but\x20not\x20spendable)\x0a'+'\x20\x203.\x20'+(ep?'THIS\x20operation\x20unwraps\x20the\x20specified\x20CoinWrapper\x20to\x20your\x20wallet':'AUTO-RECEIVE:\x20this\x20operation\x20unwraps\x20EVERY\x20CoinWrapper\x20currently\x20owned\x20by\x20you\x20in\x20a\x20single\x20transaction')+',\x20deleting\x20the\x20CoinWrapper(s)\x20and\x20transferring\x20the\x20underlying\x20coin\x20to\x20tx_context::sender\x0a'+'Requirements:\x0a'+'\x20\x20-\x20You\x20MUST\x20be\x20the\x20CoinWrapper\x27s\x20owner\x20(the\x20recipient\x20specified\x20in\x20the\x20Allocation)\x0a'+'\x20\x20-\x20type_parameter\x20is\x20OPTIONAL:\x20when\x20omitted\x20it\x20is\x20auto-derived\x20from\x20the\x20CoinWrapper\x27s\x20'+'own\x20on-chain\x20type\x20(the\x20inner\x20T\x20of\x20CoinWrapper<T>)\x0a'+(ep?'\x20\x20-\x20object\x20can\x20be\x20a\x20CoinWrapper\x20ID\x20(0x...)\x20or\x20a\x20local\x20mark\x20name\x0a':'\x20\x20-\x20When\x20\x27object\x27\x20is\x20omitted,\x20no\x20wrapper\x20lookup\x20is\x20needed\x20—\x20all\x20your\x20CoinWrappers\x20are\x20unwrapped\x20at\x20once\x0a')+'To\x20find\x20received\x20CoinWrappers:\x20call\x20query_toolkit\x20with\x20query_type=\x27onchain_received\x27\x20'+'and\x20type=\x27CoinWrapper\x27\x20for\x20your\x20account.\x0a'+'After\x20success:\x20verify\x20your\x20balance\x20increased\x20via\x20account_balance\x20query.');}else{if(ek?.['revenue']){c['push']('CREATE\x20MODE:\x20Creating\x20a\x20new\x20Payment\x20object.\x20Payments\x20are\x20IMMUTABLE\x20after\x20creation\x20—\x20'+'they\x20cannot\x20be\x20modified.\x20The\x20\x27revenue\x27\x20array\x20defines\x20the\x20recipients\x20and\x20amounts;\x20'+'ensure\x20correctness\x20before\x20submitting.\x20The\x20\x27info.for_guard\x27\x20field\x20(if\x20set)\x20binds\x20this\x20'+'Payment\x20to\x20a\x20Guard\x20for\x20conditional\x20release\x20(common\x20in\x20escrow\x20workflows).');for(let er=0x0;er<ek['revenue']['length'];er++){const es=ek['revenue'][er],et=classifyRecipient(es?.['recipient']),eu=et?.['kind']==='entity'?et['address']:undefined;if(!eu||!isValidWowAddress(eu))continue;if(objectTypeFromAddress(eu)!==ObjectType['Allocation'])continue;const ev=es?.['amount']?.['balance'];c['push']('P0\x20ALLOCATION-RECIPIENT\x20LEG\x20(irreversible\x20stranding):\x20revenue\x20leg\x20'+er+'\x20sends\x20'+((ev!=null?String(ev):'(unspecified\x20amount)')+'\x20to\x20Allocation\x20'+eu+'.\x20')+'A\x20plain\x20payment\x20delivers\x20the\x20CoinWrapper\x20OWNED\x20BY\x20the\x20Allocation\x20object\x20itself,\x20and\x20'+'no\x20allocation\x20entry\x20can\x20ever\x20unwrap\x20it\x20—\x20these\x20funds\x20have\x20NO\x20user-triggerable\x20exit\x20'+'(verified\x20precedent:\x200.01\x20permanently\x20frozen\x20inside\x20Allocation\x200x1dcf3f3a…).\x20'+'To\x20fund\x20an\x20Allocation\x27s\x20pool,\x20use\x20the\x20renewal\x20intake\x20instead\x20'+'(create\x20the\x20escrowed\x20payment\x20record,\x20have\x20the\x20allocation\x20receive\x20it,\x20then\x20create\x20the\x20payment\x20in\x20ONE\x20PTB).\x20'+'To\x20pay\x20a\x20beneficiary,\x20target\x20a\x20user\x20account\x20or\x20an\x20object\x20with\x20its\x20own\x20receive\x20entry\x20'+'(Order/Treasury).\x20Confirm\x20this\x20is\x20intentional\x20before\x20submitting\x20—\x20this\x20cannot\x20be\x20undone.');}const eq=ek?.['object']?.['type_parameter']??'0x2::wow::WOW';for(const ew of ek['revenue']){const ex=ew?.['amount'];if(ex&&typeof ex==='object'&&typeof ex['balance']==='string'){const ey=await parseAmount(ex['balance'],eq,k?.['network']);ey?.['smallestUnit']!=null&&(ex['balance']=ey['smallestUnit']<=BigInt(Number['MAX_SAFE_INTEGER'])?Number(ey['smallestUnit']):ey['smallestUnit']['toString']());}}}}const el=new CallPayment(b['data']);let em;try{em=await el['call'](k);}catch(ez){const eA=ez instanceof Error?ez['message']:String(ez);if(/is not a CoinWrapper/i['test'](eA)&&/already unwrapped or auto-claimed/i['test'](eA)){const eB=typeof b['data']?.['object']==='string'?b['data']['object']:'(unknown)';return{'content':[{'type':'text','text':'No\x20live\x20CoinWrapper\x20at\x20'+eB+'\x20—\x20this\x20id\x20is\x20NOT\x20proof\x20of\x20arrival,\x20and\x20this\x20receive\x20is\x20a\x20no-op.\x20'+'Two\x20possible\x20states,\x20discriminate\x20BEFORE\x20reporting\x20anything\x20to\x20anyone:\x20'+'(a)\x20CLAIMED:\x20it\x20was\x20a\x20CoinWrapper\x20already\x20unwrapped/claimed\x20—\x20funds\x20are\x20spendable\x20in\x20the\x20wallet;\x20'+'(b)\x20WRONG\x20ID:\x20it\x20is\x20a\x20Payment\x20(or\x20other\x20non-wrapper\x20object)\x20—\x20a\x20settlement\x20Payment\x20holds\x20'+'per-recipient\x20CoinWrappers\x20that\x20must\x20be\x20claimed\x20INDIVIDUALLY,\x20and\x20unclaimed\x20wrappers\x20hold\x20the\x20funds.\x20'+'Discriminate\x20with\x20query_toolkit\x20onchain_received\x20(lists\x20unclaimed\x20wrappers\x20owned\x20by\x20the\x20signer\x20—\x20'+'any\x20wrapper\x20under\x20a\x20Payment\x20appears\x20here\x20until\x20claimed)\x20or\x20onchain_objects\x20on\x20the\x20id\x20to\x20read\x20its\x20type.\x20'+'Do\x20NOT\x20retry\x20the\x20same\x20receive\x20and\x20do\x20NOT\x20report\x20funds\x20as\x20arrived\x20on\x20this\x20response\x20alone.'}],'structuredContent':{'outcome':'executed','result':{'type':'null'},'message':'No\x20live\x20CoinWrapper\x20at\x20'+eB+':\x20either\x20already\x20claimed\x20(funds\x20spendable)\x20or\x20a\x20non-wrapper\x20id\x20such\x20as\x20a\x20Payment\x20whose\x20per-recipient\x20CoinWrappers\x20still\x20need\x20individual\x20claims\x20—\x20discriminate\x20via\x20onchain_received\x20before\x20reporting\x20arrival.','semantic':{'intent':'payment_receive','status':'success','summary':'No-op\x20receive\x20at\x20'+eB+':\x20not\x20a\x20live\x20wrapper.\x20Arrival\x20is\x20NOT\x20proven\x20—\x20check\x20for\x20unclaimed\x20per-recipient\x20wrappers\x20(onchain_received)\x20or\x20confirm\x20the\x20prior\x20claim\x20(account_balance).','next_actions':[{'action':'List\x20unclaimed\x20wrappers','reason':'If\x20a\x20Payment\x20id\x20was\x20passed,\x20its\x20per-recipient\x20CoinWrappers\x20are\x20the\x20real\x20claim\x20targets\x20and\x20may\x20still\x20hold\x20the\x20funds','tool':'query_toolkit','priority':'critical'},{'action':'Verify\x20the\x20arrival','reason':'Only\x20account_balance\x20/\x20onchain_received\x20prove\x20funds\x20arrived\x20—\x20this\x20no-op\x20response\x20does\x20not','tool':'account_operation','priority':'recommended'}],'warnings':['Receive\x20skipped\x20for\x20'+eB+':\x20no\x20live\x20CoinWrapper\x20remains\x20under\x20this\x20id.\x20This\x20response\x20is\x20NOT\x20proof\x20that\x20funds\x20arrived\x20—\x20a\x20Payment\x20id\x20means\x20the\x20per-recipient\x20wrappers\x20were\x20never\x20touched.']}}};}throw ez;}const en=handleCallResult(em,r(b['data']));return h(t,u,b['operation_type'],em,b['data'])['catch'](()=>{}),en;}case'demand':{const eC=new CallDemand(b['data']),eD=b['submission']?await eC['call_with_submission'](k,await transformSubmission(b['submission'])):await eC['call'](k),eE=await buildGuardSubmissionPrompt(eD,'demand',{'network':k?.['network'],'signer':k?.['account'],'extra':{'demand':b['data']?.['object']}});if(eE)c['push'](eE);const eF=handleCallResult(eD,r(b['data']));return h(t,u,b['operation_type'],eD,b['data'])['catch'](()=>{}),eF;}case'order':{b['data']?.['progress']&&(c['push']('Order\x20routing\x20fact:\x20order.progress\x20runs\x20the\x20order-bound\x20path\x20—\x20it\x20passes\x20'+'namedOperator=\x22\x22\x20forwards\x20for\x20the\x20order\x20payer/agents,\x20and\x20non-empty\x20'+'namedOperator\x20or\x20permissionIndex\x20forwards\x20for\x20senders\x20entitled\x20by\x20them\x20'+'(same\x20checks\x20as\x20the\x20Progress-level\x20path).\x20On\x20an\x20order-bound\x20Progress,\x20'+'workflow_operation\x20operate\x20auto-routes\x20to\x20this\x20same\x20path.'),c['push']('Allocation\x20hint:\x20if\x20this\x20operation\x20advances\x20the\x20order\x20to\x20a\x20terminal\x20'+'state\x20(e.g.\x20Completed/Cancelled/Refunded),\x20funds\x20remain\x20in\x20the\x20'+'Allocation\x20object\x20and\x20are\x20NOT\x20auto-distributed.\x20To\x20release\x20funds,\x20'+'trigger\x20the\x20corresponding\x20Guard\x20verification\x20via\x20allocation\x20operation\x20'+'(the\x20Guard\x20bound\x20to\x20the\x20matching\x20Allocator\x20will\x20verify\x20and\x20distribute).\x20'+'Refunds\x20are\x20TWO-STEP\x20(E-4):\x20the\x20refund\x20alloc\x20pays\x20into\x20the\x20ORDER\x20object\x20'+'(only\x20the\x20order\x20owner\x20can\x20extract)\x20—\x20after\x20the\x20alloc,\x20the\x20order\x20owner\x20'+'must\x20run\x20order\x20receive\x20(e.g.\x20receive:\x27recently\x27)\x20to\x20unwrap\x20to\x20the\x20wallet;\x20'+'treat\x20\x27cancelled/refunded\x20+\x20unclaimed\x20balance\x27\x20as\x20a\x20standard\x20pending\x20task.'));const eG=b['data']?.['arb_claim_compensation'];if(eG&&typeof b['data']?.['object']==='string')try{const eL=b['data']['object'],eM=eL['startsWith']('0x')?eL:await LocalMark['Instance']()['get_address'](eL)??undefined;if(eM){const eN=await query_objects({'objects':[eM],'no_cache':!![],'network':k?.['network']}),eO=eN?.['objects']?.[0x0],eP=eO?.['data']??eO,eQ=eP?.['service'],eR=readRawOnchainAmount(eP?.['amount']);let eS;if(typeof eP?.['allocation']==='string'&&eP['allocation']['startsWith']('0x'))try{const eY=await query_objects({'objects':[eP['allocation']],'no_cache':!![],'network':k?.['network']}),eZ=eY?.['objects']?.[0x0];eS=readRawOnchainAmount(eZ?.['data']?.['balance']??eZ?.['balance']);}catch{}const eT=b['data']?.['acknowledge_dual_payout']===!![];let eU;if(eQ){const f0=await query_objects({'objects':[eQ],'no_cache':!![],'network':k?.['network']}),f1=f0?.['objects']?.[0x0];eU=readRawOnchainAmount((f1?.['data']??f1)?.['compensation_fund']);}let eV;const eW=eG?.['arb'];if(typeof eW==='string'){const f2=eW['startsWith']('0x')?eW:await LocalMark['Instance']()['get_address'](eW)??undefined;if(f2){const f3=await query_objects({'objects':[f2],'no_cache':!![],'network':k?.['network']});eV=readRawOnchainAmount(f3?.['objects']?.[0x0]?.['data']?.['indemnity']);}}const eX=arbClaimEscrowEmptyDualPayout({'orderAmount':eR,'escrowBalance':eS,'poolValue':eU,'acknowledged':eT});if(eX==='refuse')return{'content':[{'type':'text','text':'DUAL\x20PAYOUT\x20REFUSED\x20—\x20no\x20transaction\x20was\x20sent.\x20Order\x20'+eM+'\x27s\x20escrow\x20is\x20ALREADY\x20FULLY\x20RELEASED\x20(allocation\x20balance\x200\x20of\x20'+eR+')\x20and\x20this\x20arb_claim_compensation\x20would\x20stack\x20the\x20arbitration\x20compensation'+(eV!==undefined?'\x20('+eV+'\x20raw\x20units)':'')+'\x20from\x20the\x20merchant-funded\x20pool\x20on\x20top\x20of\x20that\x20completed\x20escrow\x20track.'}],'structuredContent':{'result':{'type':'error','error':'Order\x20'+eM+':\x20the\x20escrow\x20track\x20already\x20completed\x20(allocation\x20balance\x200\x20of\x20'+eR+')\x20and\x20this\x20claim\x20pays\x20the\x20arbitration\x20compensation\x20on\x20top\x20—\x20the\x20recipient\x27s\x20net\x20becomes\x20compensation\x20+\x20a\x20completed\x20escrow\x20track.\x20Confirm\x20the\x20netting\x20intent\x20before\x20the\x20chain\x20pays\x20the\x20second\x20track.','error_code':'dual_payout_unconfirmed','retryable':!![],'recovery_hint':'The\x20escrow\x20track\x20and\x20the\x20compensation\x20track\x20are\x20independent\x20by\x20design:\x20the\x20chain\x20will\x20not\x20block\x20the\x20second\x20one,\x20though\x20a\x20rail\x20paired\x20on\x20order.claimed_by\x20may\x20guard-reject\x20the\x20post-claim\x20refund\x20leg\x20—\x20that\x20rejection\x20is\x20the\x20designed\x20mutual\x20exclusion,\x20not\x20a\x20malfunction.\x20State\x20the\x20decision\x20explicitly:\x20re-send\x20the\x20SAME\x20call\x20with\x20acknowledge_dual_payout:true\x20ONLY\x20if\x20paying\x20the\x20compensation\x20on\x20top\x20of\x20the\x20fully-released\x20escrow\x20is\x20the\x20intended\x20commercial\x20outcome\x20(e.g.\x20the\x20award\x20covers\x20a\x20loss\x20the\x20escrow\x20release\x20did\x20not).\x20If\x20the\x20escrow\x20release\x20already\x20settled\x20this\x20order,\x20do\x20not\x20claim\x20—\x20verify\x20the\x20order\x20address\x20before\x20retrying.'},'message':'Refused:\x20this\x20compensation\x20claim\x20would\x20stack\x20on\x20a\x20fully-released\x20escrow.\x20Set\x20acknowledge_dual_payout:true\x20to\x20accept\x20explicitly.'}};eX==='acknowledged'&&c['push']('DUAL\x20PAYOUT\x20ACKNOWLEDGED:\x20order\x20'+eM+'\x27s\x20escrow\x20is\x20already\x20fully\x20released\x20(allocation\x20balance\x200\x20of\x20'+eR+')\x20and\x20this\x20claim\x20pays\x20the\x20arbitration\x20compensation\x20on\x20top\x20—\x20proceeding\x20on\x20the\x20explicit\x20acknowledge_dual_payout\x20flag;\x20verify\x20the\x20net\x20payout\x20per\x20party\x20is\x20the\x20intended\x20commercial\x20outcome.');if(eU===0x0&&eV!==0x0)c['push']('COMPENSATION\x20POOL\x20EMPTY:\x20the\x20Service\x27s\x20compensation_fund\x20is\x200\x20—\x20this\x20claim\x20will\x20'+'abort\x20with\x20code\x2027\x20(E_COMPENSATION_NOT_MATCH).\x20The\x20abort\x20does\x20NOT\x20consume\x20the\x20claim\x20'+'(the\x20Arb\x20stays\x20Arbitrated):\x20the\x20merchant\x20must\x20top\x20up\x20via\x20service\x20'+'compensation_fund_add\x20(>=\x20the\x20ruled\x20indemnity),\x20then\x20re-run\x20arb_claim_compensation.');else{if(eU!==undefined&&eV!==undefined&&eU<eV)c['push']('COMPENSATION\x20POOL\x20UNDERFUNDED:\x20compensation_fund\x20('+eU+'\x20raw\x20units)\x20is\x20less\x20than\x20'+('the\x20ruled\x20indemnity\x20('+eV+'\x20raw\x20units)\x20—\x20the\x20claim\x20will\x20abort\x20with\x20code\x2027.\x20')+'Merchant\x20must\x20top\x20up\x20via\x20service\x20compensation_fund_add,\x20then\x20retry\x20(the\x20abort\x20does\x20'+'not\x20consume\x20the\x20claim).');else{if(eU!==undefined&&eR!==undefined&&eR>0x0&&eU<0x3*eR)c['push']('COMPENSATION\x20COVERAGE\x20BELOW\x20CEILING:\x20compensation_fund\x20('+eU+')\x20is\x20less\x20than\x20'+('3x\x20the\x20order\x20amount\x20('+eR+')\x20—\x20the\x20chain\x20caps\x20any\x20award\x20at\x203x\x20')+'(MAX_INDEMNITY_MULTIPLE,\x20arb.move),\x20so\x20a\x20ruling\x20at\x20the\x20ceiling\x20would\x20abort\x20this\x20'+'buyer\x27s\x20payout.\x20Recommend\x20the\x20merchant\x20top\x20up\x20the\x20pool\x20via\x20service\x20'+'compensation_fund_add.\x20(Above\x203x\x20only\x20buys\x20headroom\x20for\x20concurrent\x20claims\x20—\x20'+'the\x20pool\x20is\x20per-Service\x20and\x20has\x20no\x20on-chain\x20concurrency\x20limit.)');else eU!==undefined&&eU>0x0&&c['push']('Reminder:\x20this\x20claim\x20pays\x20from\x20the\x20Service\x27s\x20merchant-prepaid\x20compensation_fund\x20pool\x20'+'(not\x20the\x20order\x20escrow).\x20Pool\x20balance\x20is\x20sufficient\x20for\x20now.\x20A\x20settled\x20claim\x20does\x20NOT\x20'+'seal\x20the\x20order:\x20a\x20later\x20refund-track\x20alloc\x20can\x20still\x20split\x20AND\x20pay\x20out\x20the\x20escrow\x20'+'(the\x20owner\x20receive\x20entries\x20are\x20deliberately\x20ungated,\x20order.move:213-234)\x20—\x20enforce\x20'+'any\x20refund-vs-claim\x20exclusion\x20by\x20gating\x20the\x20refund\x20allocator\x20on\x20order.claimed_by\x20'+'some==false\x20at\x20configuration\x20time.\x20The\x20provider\x20release\x20track\x20(direct\x20transfer)\x20'+'stays\x20usable.');}}}}catch{}const eH=new CallOrder(b['data']),eI=b['submission']?await eH['call_with_submission'](k,await transformSubmission(b['submission'])):await eH['call'](k);if(b['data']?.['receive']!=null&&eI&&typeof eI==='object'&&eI?.['effects']?.['status']?.['status']==='success'){const f4=eI['effects'],f5=Array['isArray'](f4?.['objectChanges'])?f4['objectChanges']:Array['isArray'](eI?.['objectChanges'])?eI['objectChanges']:[],f6=fb=>String(fb??'')['includes']('::coin::Coin'),f7=f5['filter'](fb=>fb?.['type']==='created'&&f6(fb?.['objectType'])),f8=f5['filter'](fb=>fb?.['type']==='mutated'&&f6(fb?.['objectType'])),f9=Array['isArray'](f4?.['balanceChanges'])?f4['balanceChanges']:[],fa=f9['length']?'Balance\x20delta\x20this\x20tx:\x20'+f9['map'](fb=>{const fc=typeof fb?.['owner']==='object'&&fb?.['owner']!==null?String(fb['owner']['AddressOwner']??fb['owner']['ObjectOwner']??''):String(fb?.['owner']??'');return(fc||'(unknown)')+'\x20'+(fb?.['amount']??'?')+'\x20('+(String(fb?.['coinType']??'')['split']('::')['pop']()??'')+')';})['join'](';\x20'):'';c['push']('RECEIVE\x20RECEIPT:\x20claimed\x20'+f7['length']+'\x20object(s)\x20into\x20the\x20wallet'+(f7['length']?'\x20('+f7['map'](fb=>fb?.['objectId'])['join'](',\x20')+')':'')+(fa?'.\x20'+fa+'.':'')+(f8['length']?'\x20'+f8['length']+'\x20existing\x20coin(s)\x20consolidated/used\x20for\x20gas\x20(mutations,\x20NOT\x20new\x20funds).':'')+(f7['length']===0x0?'\x20NO_PENDING_CLAIM:\x20this\x20enumeration\x20found\x20nothing\x20claimable\x20—\x20a\x20coin\x20merge\x20may\x20still\x20have\x20run,\x20so\x20verify\x20arrival\x20on\x20the\x20AGGREGATE\x20balance\x20(account_balance),\x20never\x20on\x20created[].':'\x20A\x20claimed\x20refund\x20typically\x20arrives\x20as\x20its\x20OWN\x20Coin\x20object\x20—\x20the\x20balance\x20aggregate\x20may\x20show\x20it\x20as\x20a\x20second\x20coin,\x20so\x20consolidate\x20before\x20pricing\x20the\x20next\x20payment.'));}if(eG){const fb=!!eI&&typeof eI==='object'&&eI?.['effects']?.['status']?.['status']==='success';let fc;if(fb&&typeof b['data']?.['object']==='string')try{const fe=b['data']['object'],ff=fe['startsWith']('0x')?fe:await LocalMark['Instance']()['get_address'](fe)??undefined;let fg;if(ff){const fh=await query_objects({'objects':[ff],'no_cache':!![],'network':k?.['network']}),fi=fh?.['objects']?.[0x0];fg=(fi?.['data']??fi)?.['progress'];}fc=await autoHoldAfterClaim(k,fe,fg);}catch{}const fd=['DUAL-TRACK\x20NOTICE\x20(NET\x20view):\x20claiming\x20compensation\x20does\x20NOT\x20adjust\x20the\x20allocation\x20—\x20'+'compensation\x20(Service\x20compensation_fund)\x20and\x20escrow\x20settlement\x20(Allocation)\x20are\x20independent\x20'+'tracks,\x20and\x20claim/objection\x20remain\x20mutually\x20exclusive\x20(claim\x20closes\x20the\x20case).\x20Buyer\x20NET\x20'+'across\x20BOTH\x20tracks\x20=\x20compensation\x20+\x20any\x20escrow\x20still\x20released\x20via\x20the\x20refund\x20track;\x20to\x20keep\x20'+'the\x20total\x20at\x20the\x20actual\x20loss,\x20keep\x20the\x20settlement\x20sealed\x20(auto-hold\x20below)\x20or\x20release\x20the\x20'+'escrow\x20only\x20through\x20acknowledge_dual_payout\x20on\x20the\x20alloc_by_guard\x20call.'];if(fc&&(fc['held']['length']||fc['notHoldable']['length']||fc['failed']['length']))fc['held']['length']&&fd['push']('Auto-hold\x20applied\x20to:\x20'+fc['held']['join'](',\x20')+'\x20—\x20a\x20courtesy\x20Progress\x20hold,\x20NOT\x20a\x20chain-level\x20freeze.\x20Forwards\x20may\x20still\x20be\x20executable\x20by\x20other\x20permissioned\x20operators\x20and\x20the\x20machine\x20keeps\x20advancing;\x20the\x20post-claim\x20fund\x20safety\x20is\x20structural\x20(a\x20second\x20payout\x20via\x20alloc\x20fails\x20—\x20allocator\x20claimed_by\x20leg),\x20not\x20a\x20settlement\x20freeze.'),fc['notHoldable']['length']&&fd['push']('NOT\x20holdable\x20by\x20this\x20account\x20(needs\x20merchant/keeper\x20to\x20run\x20order\x20hold):\x20'+fc['notHoldable']['join'](',\x20')+'.'),fc['failed']['length']&&fd['push']('Hold\x20attempted\x20but\x20failed\x20(retry,\x20or\x20have\x20merchant/keeper\x20hold\x20manually):\x20'+fc['failed']['join'](',\x20')+'.'),fc['held']['length']===0x0&&fd['push']('No\x20outgoing\x20edge\x20could\x20be\x20auto-held\x20—\x20the\x20escrow\x20settlement\x20track\x20is\x20STILL\x20OPEN;\x20'+'have\x20the\x20merchant/keeper\x20hold\x20the\x20edge(s)\x20above\x20before\x20the\x20order\x20reaches\x20completed.');else fb?fd['push']('No\x20outgoing\x20edge\x20to\x20freeze\x20at\x20the\x20current\x20node\x20(order\x20likely\x20at\x20a\x20terminal\x20node),\x20or\x20'+'edge\x20resolution\x20was\x20unavailable\x20—\x20verify\x20the\x20settlement\x20state\x20manually.'):fd['push']('The\x20claim\x20did\x20not\x20succeed,\x20so\x20no\x20hold\x20was\x20attempted;\x20rerun\x20after\x20fixing\x20the\x20cause\x20above.');c['push'](fd['join']('\x20'));if(fb&&typeof b['data']?.['object']==='string')try{const fj=b['data']['object'],fk=fj['startsWith']('0x')?fj:await LocalMark['Instance']()['get_address'](fj)??undefined;if(fk){const fl=await query_objects({'objects':[fk],'no_cache':!![],'network':k?.['network']}),fm=fl?.['objects']?.[0x0]?.['data']??fl?.['objects']?.[0x0],fn=typeof fm?.['service']==='string'?fm['service']:undefined;if(fn){const fo=await query_objects({'objects':[fn],'no_cache':!![],'network':k?.['network']}),fp=fo?.['objects']?.[0x0]?.['data']??fo?.['objects']?.[0x0],fq=fp?.['compensation_fund'],fr=typeof fq==='string'&&/^\d+$/['test'](fq['trim']())?BigInt(fq['trim']()):typeof fq==='number'&&Number['isFinite'](fq)?BigInt(Math['trunc'](fq)):undefined;if(fr!==undefined&&fr>0x0n&&Array['isArray'](fp?.['sales'])){const fs=fp['sales']['filter'](fu=>!fu?.['suspension']&&/^\d+$/['test'](String(fu?.['price']??'')['trim']()))['map'](fu=>({'name':String(fu?.['name']??''),'price':BigInt(String(fu['price'])['trim']())})),ft=computeFundListingWall(fr,fs);ft['walled']&&c['push']('FUND\x20LISTING\x20WALL\x20AFTER\x20AWARD:\x20this\x20claim\x20spent\x20the\x20Service\x27s\x20compensation\x20fund\x20—\x20the\x20live\x20fund\x20now\x20backs\x20single\x20orders\x20up\x20to\x20'+(ft['coverCap']['toString']()+'\x20base\x20units,\x20and\x20'+ft['blocked']['length']+'\x20listing(s)\x20are\x20priced\x20ABOVE\x20that\x20and\x20can\x20no\x20longer\x20be\x20checked\x20out\x20')+('(highest\x20first:\x20'+ft['blocked']['map'](fu=>fu['name']||'(unnamed)')['join'](',\x20')+').\x20The\x20buy\x20gate\x20refuses\x20those\x20orders\x20(no\x20money\x20moves)\x20until\x20the\x20fund\x20')+'is\x20topped\x20above\x203x\x20their\x20price\x20(service.compensation_fund_add)\x20or\x20the\x20price\x20is\x20cut.\x20The\x20merchant\x20should\x20re-check\x20the\x20storefront\x20—\x20'+'service_panorama\x20carries\x20the\x20live\x20wall\x20under\x20compensation_fund_listing_wall.');}}}}catch{}}const eJ=await buildGuardSubmissionPrompt(eI,'order',{'network':k?.['network'],'signer':k?.['account'],'order_address':b['data']?.['object']});if(eJ)c['push'](eJ);if(b['data']?.['order_new']&&eI&&typeof eI==='object'&&eI?.['effects']?.['status']?.['status']==='success'&&eI?.['digest']){const fu=await applyInitialForwardAfterOrderNew(b['data'],k);if(fu)c['push'](fu);}const eK=handleCallResult(eI,r(b['data']));if(eI&&typeof eI==='object'&&'digest'in eI&&eI?.['effects']?.['status']?.['status']==='success'&&b['data']?.['progress']&&typeof b['data']?.['object']==='string')try{const fv=b['data']['object'],fw=fv['startsWith']('0x')?fv:await LocalMark['Instance']()['get_address'](fv)??undefined;let fx;if(fw){const fy=await query_objects({'objects':[fw],'no_cache':!![],'network':k?.['network']}),fz=fy?.['objects']?.[0x0];fx=(fz?.['data']??fz)?.['progress'];}if(fx){const fA=b['data']['progress']?.['operation'],fB=await enrichWorkflowGuidance({'progressRef':fx,'network':k?.['network'],'accountName':k?.['account'],'noCache':!![],'txResult':eI,'dryRun':k?.['dry_run']===!![],'compact':k?.['response_level']!=='full','operate':fA?.['forward']&&fA?.['next_node_name']?{'forward':fA['forward'],'next_node_name':fA['next_node_name'],'op':b['data']['progress']?.['op']}:undefined});mergeGuidanceIntoOutput(eK,fB,{'responseLevel':k?.['response_level']});}}catch{}return h(t,u,b['operation_type'],eI,b['data'])['catch'](()=>{}),eK;}case'gen_passport':{const fC=await gen_passport(k,b['guard'],b['info']);let fD;try{const fF=Array['isArray'](fC?.['objectChanges'])?fC['objectChanges']:[],fG=fF['find'](fI=>fI?.['type']==='created'&&typeof fI?.['objectType']==='string'&&/::passport::Passport$/['test'](fI['objectType'])),fH=fG?.['objectId'];if(fH){const fI=await query_objects({'objects':[fH],'no_cache':!![],'network':k?.['network']}),fJ=fI?.['objects']?.[0x0],fK=fJ?.['data']??fJ;fK&&typeof fK==='object'&&typeof fK['result']==='boolean'&&(fD={'passport_id':fH,'result':fK['result']===!![],'has_verified':fK['has_verified']===!![],'info':Array['isArray'](fK['guard'])?fK['guard']['map'](fL=>({'guard':String(fL?.['guard']??fL??''),'result':fL?.['result']===!![],...typeof fL?.['impack']==='boolean'?{'impack':fL['impack']}:{}})):undefined});}}catch{}const fE=handleCallResult(fC,r(b['data'],undefined,fD));try{for(const fL of b['guard']??[]){const fM=typeof fL==='string'?fL:fL?.['object'];if(typeof fM!=='string'||fM==='')continue;const fN=await loadGuardJsonFromChain(fM,k?.['network']);if(!fN)continue;const fO=(fN['json']['table']??[])['some'](fP=>fP?.['identifier']===TASK_BINDING_SLOT&&fP?.['b_submission']===!![]&&fP?.['value_type']==='Address');!fO&&c['push']('PROTOCOL\x20SLOT\x20'+TASK_BINDING_SLOT+'\x20MISSING\x20on\x20Guard\x20\x27'+(fN['name']??fN['guard'])+'\x27:\x20the\x20table\x20declares\x20no\x20{identifier:\x20'+TASK_BINDING_SLOT+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20row\x20(task\x20binding).\x20A\x20passport\x20built\x20now\x20can\x20never\x20satisfy\x20the\x20on-chain\x20task-binding\x20check\x20on\x20an\x20order-driven\x20Progress\x20forward\x20(abort\x20code\x2011)\x20—\x20the\x20passport\x20only\x20emits\x20DECLARED\x20table\x20rows.\x20Fix\x20BEFORE\x20binding/publishing:\x20export\x20the\x20guard\x20(guard2file),\x20add\x20the\x20'+TASK_BINDING_SLOT+'\x20declaration,\x20create\x20a\x20NEW\x20Guard,\x20and\x20rebind\x20—\x20tables\x20freeze\x20at\x20creation.');}}catch{}return h(t,u,b['operation_type'],fC,b['data'])['catch'](()=>{}),fE;}case'proof':{const fP=new CallProof(b['data']),fQ=b['submission']?await fP['call_with_submission'](k,await transformSubmission(b['submission'])):await fP['call'](k),fR=await buildGuardSubmissionPrompt(fQ,'proof',{'network':k?.['network'],'signer':k?.['account']});if(fR)c['push'](fR);const fS=handleCallResult(fQ,r(b['data']));return h(t,u,b['operation_type'],fQ,b['data'])['catch'](()=>{}),fS;}case'gen_proof':{const fT=await gen_proof(k,b['proof'],b['server_pubkey'],b['server_signature'],b['proof_type'],b['description'],b['item_count'],b['about_address']),fU=handleCallResult(fT,r(b['data']));return h(t,u,b['operation_type'],fT,b['data'])['catch'](()=>{}),fU;}}const A=b;throw new Error('Unknown\x20on-chain\x20operation\x20type:\x20'+String(A['operation_type']));}catch(fV){let fW=fV instanceof Error?fV['message']:String(fV);const fX=b?.['operation_type'],fY=b&&'data'in b?b['data']:undefined,fZ=b&&b['env']?b['env']['network']:undefined;try{const g4=await diagnoseGuardFailure(b,fW);if(g4)fW=fW+'\x0a'+g4;}catch{}const g0=fV?.['digest'],g1=typeof g0==='string'&&g0?g0:undefined;let g2;const g3=b?.['env']?.['dry_run']===!![]||/MoveAbort|abort code|has been deleted/i['test'](fW);if(fX&&!g3){const g5=markerOpFor(fX,fY),g6=b?.['env'],g7=fY!==undefined?fY:b,g8=b?.['submission'];parkUnknownOutcomeMarker(g5,g7,g6,g8);const g9=lastInFlightMarker(g5,inFlightParamsHash(g7,g8,g6?.['account'])),ga=[...g1?[g1]:[],...g9?.['digests']??[]]['filter']((gb,gc,gd)=>gd['indexOf'](gb)===gc);g6?.['account']&&(g2={'sender':g6['account'],'failed_at':new Date()['toISOString'](),'verify_events_since':new Date(Date['now']()-0x5a*0x3e8)['toISOString'](),'digests':ga});}if(fX==='service'&&fY?.['order_new']){if(!g3){const gb=inFlightParamsHash(fY,undefined,b?.['env']?.['account']),gc=markerOpFor(fX,fY);if(g1)attachInFlightDigest(gc,gb,g1);const gd=await verifyOrderNewLanded(fZ,gb)['catch'](()=>undefined),ge=gd??describeLastInFlight(gc,gb);if(ge)fW=fW+'\x0a'+ge;}}if(fX==='allocation'&&fY?.['alloc_by_guard']){if(!g3){const gf=inFlightParamsHash(fY,b['submission'],b['env']?.['account']),gg=markerOpFor(fX,fY);if(g1)attachInFlightDigest(gg,gf,g1);const gh=describeLastInFlight(gg,gf);if(gh)fW=fW+'\x0a'+gh;}}try{const gi=await resolveNetwork(fZ);fW+=fZ?'\x0a[network:\x20attempted\x20=\x20'+gi+'\x20(explicitly\x20requested)]':'\x0a[network:\x20attempted\x20=\x20'+gi+'\x20(session\x20default\x20—\x20pass\x20env.network\x20to\x20pin\x20a\x20specific\x20network)]';}catch{}return handleCallResult({'error':fW},fX?{'operation_type':fX,'data':fY,'operation_id':stableOperationId(fX,fY),'submission_verification':g2}:undefined);}}
|
|
1
|
+
import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{resolve,dirname,join}from'path';import{getWowMcpDir,WowClient,getFullnodeUrl}from'@wowok/wowok';import{diagnose_passport_failure,verifyGuardFailureLegs,CallService,CallMachine,CallProgress,CallGuard,CallArbitration,CallRepository,CallContact,CallTreasury,CallReward,CallAllocation,CallPersonal,CallPayment,CallDemand,CallOrder,gen_passport,CallProof,gen_proof,ResponseData,LocalMark,query_objects,query_table,query_serviceContext,parseGuardFile,formatGuardParseErrors,transformRewardInput,transformPersonalInput,GetAccountOrMark_Address,Config,query_events,ObjectType,objectTypeFromAddress,isValidWowAddress,bcs,deriveDynamicFieldID,PackageAddress}from'@wowok/wowok';import{buildReceipt}from'../../schema/call/receipt.js';import{buildOrderFundFacts}from'../../knowledge/arb-fund-facts.js';import{recordMachineCreation}from'../../knowledge/machine-fork-watch.js';import{TASK_BINDING_SLOT}from'../../knowledge/onchain-constants.js';import{computeFundListingWall}from'../../graph/onchain/facts.js';import{renderGuardLegMap}from'../../knowledge/guard-leg-map.js';import{beginInFlight,recordInFlightOutcome,consumeInFlightMarker,describeLastInFlight,inFlightParamsHash,lastInFlightMarker,matchOrderLandedEvent,matchRecentOrder,pendingInFlightResend,attachInFlightDigest,parkUnknownOutcomeMarker,markerOpFor}from'../../composition/inflight.js';import{preflightPlan}from'../../composition/materialize.js';import{OnchainOperationsSchema,strictParse,getEnvConfig,handleCallResult,checkClientSchemaCompatibility,parseMachineNodesFromText,formatNodeErrors as a523a,machinePublishGateViolation,transformSubmission}from'../../schema/index.js';import{handlePermissionOperations}from'../../schema/call/permission-handler.js';import{resolveNetwork}from'./network.js';import{collectPermissionIndexes,checkPermissionAuthorization,formatPermissionWarning}from'../../schema/utils/permission-machine-check.js';import{getSkillsHintForOnchain}from'../../schema/utils/skills-recommendation.js';import{fetchEntityPermissions}from'../../playbooks/service-build/participation-radar.js';import{prepareFundOperation,parseAmount,generateSkillsHint as a523b,formatChainValue,fundWaterReminder}from'../../knowledge/fund-layer.js';import{generateGuardSubmissionPrompt,formatSubmissionPrompt}from'../../knowledge/guard-submission-prompt.js';import{classifyRecipient,classifyDualPayoutTrack}from'../../knowledge/recipient-constraint.js';import{auditService,formatTaskBindingAdvisory,lintTaskBindingAdvisories,REFUND_RAIL_NODE_REGEX}from'../../knowledge/audit-rules.js';import{translateGuardTypeError}from'../../knowledge/guard-lint.js';import{lintGuardNodeGates,parseGuardNodeGates,recordMachineNodeNames}from'../../knowledge/guard-node-gates.js';import{getGuardQueryByIdOrName}from'../../schema/utils/guard-query-utils.js';import{checkArbitrationVenueOrder,venueOperatingDoctrine}from'../../knowledge/arbitration-venue-order.js';import{assessAllocationRisks}from'../../knowledge/allocation-risk.js';import{ENTITY_RECIPIENT_RULE_ID,checkEntityRecipients,describeEntityRecipients,formatEntityRecipientViolation}from'../../knowledge/entity-recipient-guard.js';import{checkDiscountThresholdBeforeBuy,checkDiscountFloorBeforeIssue,describeBenchmarkIssueRisk}from'../../knowledge/discount-threshold.js';import{priorProofConsumptions,recordProofConsumption}from'../../communication/proof-reuse.js';import{evaluateServiceFromGraph}from'../../playbooks/service-build/topology-query.js';import{isEnabled as a523c,isDualPayoutPreauthorized,getStoreDualPayoutPolicy}from'../../config/index.js';import{buildSubmissionConfirmation,diffGuardSpecVsChain,loadGuardJsonFromChain,OPERATION_GUARD_ACTION}from'../../knowledge/guard-submission-brief.js';import{enrichWorkflowGuidance,mergeGuidanceIntoOutput,resolveHoldableEdges,extractObjectVersionFromTx,extractProgressEventNodeFromTx}from'../../knowledge/workflow-guidance.js';import{runReviewChain,runReviewRepositoryWrite,runReviewRewardClaim,mergeReviewStepsIntoOutput}from'./review-chain.js';import{parseGuardTimeBounds,recordGuardTimeProfile,checkGuardAnchorReachability,formatGuardAnchorWarnings}from'../../knowledge/guard-anchor-reach.js';import{batchQueryObjectsByIds,batchReadAddressKeyedFields,fetchMachineNodes,fetchServiceOrders}from'../../graph/onchain/sdk-batch.js';import{normAddr,rootOf}from'../../graph/onchain/extract.js';import{classifyWipPath,probeWipReachability}from'../wip-deploy-assist.js';import{declareDispatchExpectation}from'./dispatch-expectations.js';import{stableOperationId}from'../../harness/operation-id.js';import{collectOnChainNamedObjectRequests,registerLocalMarksForCreatedObjects,planAutoLocalMark,operationPrimaryType,autoLocalMarkName}from'./onchain-name-registration.js';import{goalEngine}from'../../goal/GoalEngine.js';async function buildGuardSubmissionPrompt(a,b,c){if(!a||typeof a!=='object'||!('submission'in a))return undefined;const d=a['submission'];if(!Array['isArray'](d)||d['length']===0x0)return undefined;const f=d[0x0]?.['guard'];if(!f)return undefined;try{const g=await generateGuardSubmissionPrompt(f,{'operation':b,...c});return g?formatSubmissionPrompt(g):undefined;}catch(h){return'SUBMISSION\x20REQUIRED\x20—\x20the\x20Guard\x20needs\x20data\x20you\x20have\x20not\x20supplied\x20yet\x20(detailed\x20prompt\x20generation\x20'+('failed:\x20'+(h?.['message']??String(h))+').\x20Retry\x20with\x20the\x20submission\x20envelope\x20per\x20')+'SubmissionCallSchema:\x20{type:\x22submission\x22,\x20guard:[{object:\x22<guard\x20id>\x22,\x20impack:true}],\x20'+'submission:[{identifier:<n>,\x20value:\x22<value>\x22}]}\x20—\x20the\x20identifiers\x20above\x20name\x20every\x20required\x20field.';}}function treeUsesRewardRecords(a){if(!a||typeof a!=='object')return![];if(a['type']==='query_reward_record_exists')return!![];if(a['type']==='query'&&typeof a['query']==='string'&&/^reward\.record\.(exists_where|count_where|find_where|exists|count|find)$/['test'](a['query']))return!![];const b=[...Array['isArray'](a['nodes'])?a['nodes']:[],...Array['isArray'](a['and'])?a['and']:[],...Array['isArray'](a['or'])?a['or']:[],a['node'],a['left'],a['right']];return b['some'](d=>d&&typeof d==='object'&&treeUsesRewardRecords(d));}function treePinsRecordStamp(a){if(!a||typeof a!=='object')return![];const b=a['type']==='query_reward_record_exists'||a['type']==='query'&&typeof a['query']==='string'&&/^reward\.record\.(exists_where|count_where|find_where|exists|count|find)$/['test'](a['query']);if(b&&(a['where']?.['storeFromId']!=null||a['storeFromId']!=null))return!![];const c=[...Array['isArray'](a['nodes'])?a['nodes']:[],...Array['isArray'](a['and'])?a['and']:[],...Array['isArray'](a['or'])?a['or']:[],a['node'],a['left'],a['right']];return c['some'](d=>d&&typeof d==='object'&&treePinsRecordStamp(d));}export async function assertRewardReplayStamp(a,b,c=[]){if(!Array['isArray'](a))return;for(const d of a){if(!d||typeof d!=='object'||d['store_from_id']!=null)continue;let e,f;try{const h=await loadGuardJsonFromChain(String(d['guard']),b);h&&(e=treeUsesRewardRecords((h['json']??{})['root']),f=treePinsRecordStamp((h['json']??{})['root']));}catch{e=undefined;}if(e===!![]&&f===!![])throw new Error('reward.guard_add\x20REJECTED:\x20guard\x20\x27'+String(d['guard'])+'\x27\x20pins\x20a\x20storeFromId\x20predicate\x20'+'(order-scoped\x20record\x20query)\x20but\x20the\x20entry\x20omits\x20store_from_id\x20—\x20claim\x20records\x20are\x20written\x20'+'unstamped\x20and\x20match\x20NO\x20store_from\x20predicate,\x20so\x20the\x20per-order\x20leg\x20silently\x20never\x20fires\x20'+'(the\x20protocol\x20claim\x20key\x20still\x20bounds\x20each\x20recipient\x20to\x20one\x20claim,\x20but\x20the\x20once-per-order\x20'+'economics\x20the\x20tree\x20declares\x20are\x20dead).\x20Re-submit\x20with\x20store_from_id\x20=\x20the\x20table\x20identifier\x20'+'whose\x20submitted\x20value\x20identifies\x20the\x20claim\x20(slot\x200\x20—\x20the\x20submitted\x20Order\x20address\x20—\x20is\x20the\x20'+'conventional\x20once-per-order\x20stamp);\x20re-adding\x20the\x20SAME\x20guard\x20overwrites\x20its\x20slot\x20in\x20place.');if(e===!![]){c['push']('RECIPIENT-ONCE\x20REWARD\x20GUARD:\x20guard_add\x20for\x20\x27'+String(d['guard'])+'\x27\x20omits\x20store_from_id\x20and\x20its\x20record\x20'+'queries\x20pin\x20no\x20storeFromId\x20predicate\x20—\x20claims\x20are\x20bounded\x20by\x20the\x20protocol\x20claim\x20key\x20to\x20once\x20'+'per\x20recipient\x20for\x20life\x20(query\x20record-exists\x20is\x20recipient-scoped,\x20defaulting\x20to\x20the\x20signer;\x20the\x20'+'order.owner\x20identity\x20leg\x20is\x20what\x20decides\x20WHO\x20may\x20claim\x20—\x20keep\x20it).\x20If\x20once-per-ORDER\x20economics\x20'+'are\x20intended\x20instead,\x20re-add\x20with\x20store_from_id\x20pinned\x20(slot\x200\x20=\x20submitted\x20Order\x20address)\x20and\x20'+'an\x20order-scoped\x20where:{storeFromId:{identifier:<slot>}}\x20leg;\x20re-adding\x20the\x20SAME\x20guard\x20overwrites\x20'+'its\x20slot\x20in\x20place.\x20If\x20once-per-recipient\x20is\x20intended,\x20ignore\x20this\x20warning.');continue;}c['push']('REPLAY-OPEN\x20REWARD\x20GUARD:\x20guard_add\x20for\x20\x27'+String(d['guard'])+'\x27\x20omits\x20store_from_id\x20—\x20equality-based\x20per-order\x20dedup\x20can\x20never\x20'+'match\x20(records\x20without\x20the\x20pinned\x20value\x20match\x20NO\x20store_from_id\x20predicate;\x20slot-less\x20guards\x20can\x20only\x20dedup\x20'+'lifetime-once\x20via\x20record\x20count/exists\x20with\x20an\x20empty\x20where).\x20If\x20per-order\x20protection\x20is\x20intended,\x20re-add\x20'+'with\x20store_from_id\x20pinned\x20(slot\x200\x20=\x20submitted\x20Order\x20address\x20is\x20the\x20conventional\x20per-order\x20stamp;\x20re-adding\x20'+'the\x20SAME\x20guard\x20overwrites\x20its\x20slot\x20in\x20place,\x20so\x20existing\x20pools\x20can\x20be\x20repaired\x20without\x20a\x20new\x20guard);\x20'+'if\x20unlimited\x20repeat\x20claims\x20are\x20intended,\x20ignore\x20this\x20warning.');}}function recordStampSlots(a,b=[]){if(!a||typeof a!=='object')return b;const d=a['type']==='query_reward_record_exists'||a['type']==='query'&&typeof a['query']==='string'&&/^reward\.record\.(exists_where|count_where|find_where|exists|count|find)$/['test'](a['query']);if(d){const f=a['where']?.['storeFromId']??a['storeFromId'],g=f&&typeof f==='object'?f['identifier']:f;if(typeof g==='number'&&Number['isFinite'](g))b['push'](g);}const e=[...Array['isArray'](a['nodes'])?a['nodes']:[],...Array['isArray'](a['and'])?a['and']:[],...Array['isArray'](a['or'])?a['or']:[],a['node'],a['left'],a['right']];for(const h of e){if(h&&typeof h==='object')recordStampSlots(h,b);}return b;}export async function checkRewardOnceArming(a,b,c=[]){if(!a||typeof a!=='object')return;const e=a,f=Array['isArray'](e['guard_add'])?e['guard_add']:[];for(const h of f){if(!h||typeof h!=='object')continue;const i=h;if(i['store_from_id']==null)continue;let j;try{const m=await loadGuardJsonFromChain(String(i['guard']),b);if(!m)continue;j=(m['json']??{})['root'];}catch{continue;}const k=recordStampSlots(j);if(k['includes'](Number(i['store_from_id'])))continue;const l=k['length']>0x0?k['join'](',\x20'):'none';c['push']('REWARD\x20ONCE\x20ARM\x20NOT\x20DETECTED\x20(advisory,\x20never\x20blocking):\x20reward.guard_add\x20for\x20\x27'+String(i['guard'])+'\x27\x20'+('pins\x20store_from_id='+String(i['store_from_id'])+',\x20but\x20the\x20guard\x20tree\x20carries\x20no\x20matching\x20order-scoped\x20')+('record\x20leg\x20(storeFromId\x20slots\x20found:\x20'+l+').\x20The\x20stamp\x20alone\x20is\x20not\x20a\x20claim\x20boundary:\x20reward.claim\x20')+'keys\x20every\x20payout\x20on\x20RewardClaimKey{recipient,\x20guard,\x20store_from},\x20the\x20stamped\x20value\x20comes\x20from\x20the\x20'+'claimant\x27s\x20own\x20submission,\x20and\x20with\x20an\x20EMPTY\x20store_from\x20slot\x20the\x20payout\x20degrades\x20to\x20ONE\x20claim\x20per\x20'+'(recipient,\x20guard)\x20for\x20life\x20—\x20the\x20buyer\x27s\x20second\x20order\x20aborts\x2013\x20(E_CLAIM_ALREADY_MADE).\x20'+'Remediation:\x20(1)\x20add\x20logic_not({type:\x27query_reward_record_exists\x27,\x20object:{identifier:<reward\x20slot>},\x20'+('where:{storeFromId:{identifier:'+String(i['store_from_id'])+'}}})\x20to\x20the\x20guard\x20root\x20and\x20keep\x20the\x20SAME\x20')+'slot\x20stamped\x20on\x20guard_add\x20(re-adding\x20the\x20guard\x20overwrites\x20its\x20slot\x20in\x20place;\x20guards\x20are\x20immutable\x20but\x20'+'the\x20Reward\x27s\x20guard\x20entry\x20is\x20not);\x20(2)\x20for\x20a\x20per-order\x20once\x20the\x20chain\x20itself\x20enforces,\x20route\x20the\x20'+('incentive\x20through\x20an\x20Allocation\x20leg\x20that\x20declares\x20protocol\x20slot\x20'+TASK_BINDING_SLOT+'\x20')+'(the\x20once\x20key\x20derives\x20from\x20bcs(payment_info.for_object);\x20a\x20second\x20alloc\x20aborts\x2016).\x20'+'If\x20this\x20guard\x20deliberately\x20dedups\x20on\x20another\x20state,\x20ignore\x20this\x20warning.');}f['length']===0x0&&e['coin_add']!=null&&await warnFundingOnUnarmedReward(e['object'],b,c);}async function warnFundingOnUnarmedReward(a,b,c){try{if(typeof a!=='string'||a['length']===0x0)return;let d=a;!d['startsWith']('0x')&&(d=await LocalMark['Instance']()['get_address'](d));if(!d)return;const e=await query_objects({'objects':[d],'network':b}),f=Array['isArray'](e?.['objects'])?e['objects'][0x0]:undefined,h=Array['isArray'](f?.['guards'])?f['guards']:[];for(const i of h){if(!i||typeof i!=='object'||i['store_from_id']!=null)continue;c['push']('REWARD\x20FUNDING\x20ON\x20A\x20LIFETIME-ONCE\x20POOL\x20(advisory,\x20never\x20blocking):\x20reward\x20'+('\x27'+d+'\x27\x20is\x20funded\x20while\x20mounted\x20guard\x20\x27'+String(i['guard'])+'\x27\x20carries\x20NO\x20store_from_id.\x20')+'reward.claim\x20keys\x20every\x20payout\x20on\x20RewardClaimKey{recipient,\x20guard,\x20store_from}:\x20an\x20empty\x20'+'store_from\x20slot\x20is\x20ONE\x20claim\x20per\x20(recipient,\x20guard)\x20for\x20LIFE,\x20so\x20the\x20same\x20buyer\x27s\x20second\x20order\x20'+'aborts\x2013\x20(E_CLAIM_ALREADY_MADE)\x20and\x20the\x20bounty\x20silently\x20pays\x20once.\x20'+'Remediation:\x20re-add\x20the\x20SAME\x20guard\x20with\x20store_from_id\x20pinned\x20(slot\x200\x20=\x20the\x20submitted\x20Order\x20'+'address\x20is\x20the\x20conventional\x20per-order\x20stamp;\x20re-adding\x20overwrites\x20its\x20slot\x20in\x20place)\x20plus\x20an\x20'+'order-scoped\x20where:{storeFromId:{identifier:<slot>}}\x20record\x20leg,\x20or\x20route\x20the\x20incentive\x20through\x20'+('an\x20Allocation\x20leg\x20armed\x20with\x20protocol\x20slot\x20'+TASK_BINDING_SLOT+'.\x20Funding\x20does\x20not\x20repair\x20the\x20claim\x20shape.'));}}catch{}}function assertRewardRecipientSemantics(a){if(!Array['isArray'](a))return;for(const b of a){if(!b||typeof b!=='object')continue;const c=b['recipient'];if(c!==null&&typeof c==='object'&&'GuardIdentifier'in c)throw new Error('reward.guard_add\x20REJECTED:\x20the\x20entry\x20for\x20guard\x20\x27'+String(b['guard'])+'\x27\x20'+'declares\x20recipient\x20{GuardIdentifier:\x20N}\x20—\x20the\x20claim\x20entry\x20requires\x20recipient\x20==\x20the\x20transaction\x20'+'sender\x20(reward\x20rail\x20abort\x2014,\x20E_CLAIM_RECIPIENT_NOT_SIGNER),\x20and\x20a\x20GuardIdentifier\x20resolves\x20from\x20'+'the\x20passport\x20submission\x20(conventionally\x20the\x20submitted\x20Order\x20address),\x20which\x20can\x20never\x20be\x20the\x20'+'signer:\x20the\x20entry\x20is\x20structurally\x20unpayable,\x20every\x20claim\x20aborts\x20(crs-mn-261015\x20F-12,\x20live\x20mainnet).\x20'+'Use\x20recipient\x20{Signer:\x20\x27signer\x27}\x20—\x20the\x20claim\x20guard\x27s\x20order.owner\x20identity\x20leg\x20keeps\x20it\x20buyer-bound\x20—\x20'+'or\x20an\x20{Entity}\x20recipient\x20(the\x20SDK\x20replaces\x20it\x20with\x20the\x20claimant\x27s\x20local\x20account\x20at\x20claim\x20time).\x20'+'The\x20GuardIdentifier\x20order-anchor\x20idiom\x20belongs\x20to\x20ALLOCATION\x20rails\x20only\x20(money\x20lands\x20ON\x20the\x20Order).');}}export async function verifyRewardEvidenceBindings(a,b,c,d){const e=[];if(!Array['isArray'](c))return e;const f=c['filter'](p=>p&&typeof p==='object'&&p['evidence']!=null);if(f['length']===0x0)return e;const h=buildReceipt(a);if(h['kind']!=='transaction'||!h['executed'])return e;const i=async p=>{if(typeof p!=='string'||!p)return undefined;if(p['startsWith']('0x'))return p;try{return await LocalMark['Instance']()['get_address'](p)??undefined;}catch{return undefined;}},j=p=>{if(typeof p==='string')return'\x22'+p+'\x22';if(Array['isArray'](p))try{return'\x22'+new TextDecoder()['decode'](new Uint8Array(p))+'\x22';}catch{return'bytes['+p['length']+']';}return'?';},k=await i(typeof b==='string'?b:b&&typeof b==='object'?b['object']:undefined);if(!k)return e['push']('EVIDENCE\x20BINDING\x20READBACK\x20INCOMPLETE\x20(ksr-tn-261026\x20Q8-F04\x20contract):\x20the\x20call\x20requested\x20a\x20native\x20'+'evidence\x20pin\x20but\x20the\x20reward\x20object\x20reference\x20was\x20not\x20resolvable\x20on\x20this\x20process,\x20so\x20the\x20pin\x20could\x20'+'NOT\x20be\x20verified.\x20Do\x20not\x20treat\x20the\x20request\x20as\x20honored\x20—\x20verify\x20the\x20pin\x20on\x20chain\x20(query\x20the\x20reward\x20'+'object\x27s\x20dynamic\x20fields\x20for\x20the\x20evidence\x20key)\x20before\x20relying\x20on\x20claim-time\x20evidence\x20counting.'),e;const l=[];for(const p of f){const q=p,s=await i(q['guard']);if(!s)continue;const t=deriveDynamicFieldID(k,PackageAddress+'::reward::EvidenceKey',bcs['Address']['serialize'](s)['toBytes']())['toLowerCase']();l['push']({'guardLabel':String(q['guard']),'fieldId':t,'key':j(q['evidence']['key'])});}if(l['length']===0x0)return e['push']('EVIDENCE\x20BINDING\x20READBACK\x20INCOMPLETE\x20(ksr-tn-261026\x20Q8-F04\x20contract):\x20the\x20call\x20requested\x20a\x20native\x20'+'evidence\x20pin\x20but\x20the\x20guard\x20reference\x20was\x20not\x20resolvable\x20on\x20this\x20process,\x20so\x20the\x20pin\x20could\x20NOT\x20be\x20'+'verified.\x20Do\x20not\x20treat\x20the\x20request\x20as\x20honored\x20—\x20verify\x20the\x20pin\x20on\x20chain\x20before\x20relying\x20on\x20'+'claim-time\x20evidence\x20counting.'),e;const m=new Set();let n=![];try{const u=await query_objects({'objects':l['map'](v=>v['fieldId']),'network':d});for(const v of u?.['objects']??[]){const x=String(v?.['object']??'')['toLowerCase']();if(x)m['add'](x);}}catch{n=!![];}if(n)return e['push']('EVIDENCE\x20BINDING\x20UNVERIFIED\x20(ksr-tn-261026\x20Q8-F04\x20contract):\x20the\x20read-back\x20query\x20failed,\x20so\x20the\x20'+'requested\x20evidence\x20pin(s)\x20on\x20reward\x20'+k+'\x20could\x20not\x20be\x20confirmed.\x20Verify\x20on\x20chain\x20'+'(query\x20the\x20reward\x20object\x27s\x20dynamic\x20fields)\x20before\x20relying\x20on\x20claim-time\x20evidence\x20counting;\x20a\x20'+'silently-dropped\x20pin\x20is\x20a\x20KNOWN\x20failure\x20mode\x20on\x20packages\x20without\x20the\x20native\x20evidence-pinning\x20entry.'),e;for(const y of l){m['has'](y['fieldId'])?e['push']('EVIDENCE\x20BINDING\x20VERIFIED\x20(ksr-tn-261026\x20Q8-F04\x20contract):\x20guard\x20'+y['guardLabel']+'\x20on\x20reward\x20'+k+'\x20carries\x20its\x20on-chain\x20evidence\x20pin\x20(key\x20'+y['key']+')\x20—\x20claim-time\x20counting\x20is\x20'+'native\x20and\x20only\x20repository\x20rows\x20tied\x20to\x20THIS\x20claim\x27s\x20own\x20store_from\x20value\x20can\x20satisfy\x20it.'):e['push']('EVIDENCE\x20BINDING\x20NOT\x20ON\x20CHAIN\x20(ksr-tn-261026\x20Q8-F04\x20contract):\x20guard\x20'+y['guardLabel']+'\x20on\x20reward\x20'+k+'\x20requested\x20an\x20evidence\x20pin\x20(key\x20'+y['key']+')\x20but\x20the\x20reward\x20object\x20carries\x20NO\x20'+'evidence\x20field\x20for\x20it.\x20On\x20the\x20currently\x20deployed\x20package\x20the\x20native\x20evidence-pinning\x20capability\x20'+'is\x20unavailable:\x20batch\x20submissions\x20SILENTLY\x20DROP\x20the\x20pin\x20and\x20the\x20direct\x20face\x20fails\x20with\x20a\x20'+'missing-entry\x20error\x20(classified\x20capability_unavailable,\x20non-retryable).\x20The\x20claim\x20still\x20passes\x20'+'on\x20the\x20repository-floor\x20guard\x20leg,\x20which\x20proves\x20only\x20\x27a\x20qualifying\x20repository\x20row\x20exists\x20for\x20'+'this\x20order\x27\x20—\x20NOT\x20who\x20wrote\x20it\x20or\x20that\x20the\x20attested\x20event\x20really\x20happened;\x20disclose\x20that\x20'+'boundary\x20wherever\x20the\x20bounty\x20is\x20advertised.\x20Do\x20NOT\x20re-send\x20guard_add\x20to\x20\x27fix\x27\x20this\x20—\x20re-enable\x20'+'the\x20pin\x20only\x20after\x20the\x20network\x27s\x20package\x20ships\x20the\x20capability\x20(release\x20notes,\x20not\x20the\x20runtime).');}return e;}function chainForwardGuardRef(a){const b=a?.['guard'];return typeof b==='string'?b:typeof b?.['guard']==='string'?b['guard']:'';}async function fetchChainAnchorContext(a,b){try{if(typeof a!=='string'||a['trim']()==='')return undefined;let c=a['trim']();if(!c['startsWith']('0x')){const j=await LocalMark['Instance']()['get'](c);if(!j?.['address'])return undefined;c=j['address'];}const d=await query_table({'parent':c,'network':b?.['network']}),e=(d?.['items']??[])['map'](k=>k?.['object'])['filter'](k=>typeof k==='string'&&k['length']>0x0);if(e['length']===0x0)return undefined;const f=await query_objects({'objects':e,'network':b?.['network']}),g=(f?.['objects']??[])['filter'](k=>k?.['type']==='TableItem_MachineNode')['map'](k=>({'name':k['name'],'pairs':k['value']}));if(g['length']===0x0)return undefined;const h=new Set();for(const k of g){for(const l of k['pairs']??[]){for(const m of l?.['forwards']??[]){const o=chainForwardGuardRef(m);if(o)h['add'](o);}}}const i=new Map();for(const q of h){try{let r=q;if(!r['startsWith']('0x')){const v=await LocalMark['Instance']()['get'](r);if(!v?.['address'])continue;r=v['address'];}const s=await query_objects({'objects':[r],'network':b?.['network']}),t=s?.['objects']?.[0x0];if(!t||t['type']!=='Guard')continue;const u=parseGuardTimeBounds(t['root'],t['table']);if(!u)continue;i['set'](r['toLowerCase'](),u),i['set'](q['trim']()['toLowerCase'](),u);}catch{}}return{'nodes':g,'profiles':i};}catch{return undefined;}}async function maybeGuardSubmissionConfirmation(a,b){const d=[],e=a['submission'];if(e&&typeof e==='object'&&Array['isArray'](e['submission']))for(const l of e['submission']){l?.['guard']&&Array['isArray'](l['submission'])&&l['submission']['length']>0x0&&d['push']({'guardRef':String(l['guard']),'items':l['submission']});}const f=a['info'];if(f&&typeof f==='object'&&Array['isArray'](f['submission'])&&f['submission']['length']>0x0){const m=Array['isArray'](f['guard'])?f['guard']['map'](o=>o?.['object'])['filter'](Boolean):[],n=m[0x0]?String(m[0x0]):a['guard'];if(n)d['push']({'guardRef':String(n),'items':f['submission']});}if(d['length']===0x0)return undefined;const g=OPERATION_GUARD_ACTION[a['operation_type']],h=[];for(const o of d){const q=await buildSubmissionConfirmation({'guard_ref':o['guardRef'],'submission':o['items'],...g?{'action':g}:{},'network':b['network']});if(q)h['push'](q);}if(h['length']===0x0)return undefined;const i=h['map'](r=>r['confirmation_text'])['join']('\x0a\x0a'),j=[];for(const r of h){r['missing_identifiers']['length']>0x0&&j['push']('Guard\x20'+(r['guard_name']??r['guard'])+':\x20missing\x20required\x20identifier(s)\x20'+r['missing_identifiers']['join'](',\x20'));for(const s of r['items']){for(const t of s['issues']){j['push']('Guard\x20'+(r['guard_name']??r['guard'])+'\x20['+(s['identifier']??'?')+']:\x20'+t);}}}const k={'message':i,'result':{'type':'pending_confirmation','preview':{'level':'standard','operation':a['operation_type'],'object':h[0x0]['guard_name']??h[0x0]['guard'],'network':b['network'],...j['length']>0x0?{'warnings':j}:{}},'rule_id':'guard_submission_confirm'},'semantic':{'intent':a['operation_type']+'_guard_submission_awaiting_confirmation','status':'pending_input','summary':'Guard\x20submission\x20composed-confirmation\x20(G1):\x20the\x20complete\x20semantics\x20of\x20your\x20submission\x20'+'(guard\x20rules\x20+\x20your\x20values\x20+\x20pass/fail\x20consequences)\x20are\x20shown\x20in\x20the\x20message.\x20'+'The\x20operation\x20was\x20NOT\x20executed.\x20Re-call\x20with\x20env.confirmed=true\x20to\x20proceed.','next_actions':[{'action':'confirm:\x20re-call\x20the\x20SAME\x20operation\x20with\x20env.confirmed=true','reason':'Guard\x20submission\x20confirmation\x20—\x20'+h['length']+'\x20guard(s),\x20'+d['reduce']((u,v)=>u+v['items']['length'],0x0)+'\x20submitted\x20item(s).','tool':'onchain_operations','priority':'required'}],...j['length']>0x0?{'warnings':j}:{}}};return{'content':[{'type':'text','text':i}],'structuredContent':k};}const REFERRER_FILE=join(getWowMcpDir(),'referrer');function readStoredReferrer(){try{if(!existsSync(REFERRER_FILE))return null;const a=readFileSync(REFERRER_FILE,'utf8')['trim']();return a||null;}catch{return null;}}const PROJECT_SKILL_DIRS=['.claude/skills','.agents/skills','.cursor/rules','.github/prompts','.windsurf/skills','.codex/skills','.qoder/skills','.roo/skills','.codebuddy/skills'],PROJECT_SKILL_MARKERS=['wowok-provider','wowok-supplier','wowok-collaborator','wowok-arbitrator','wowok-order','wowok-messenger','wowok-machine','wowok-output','wowok-onboard','wowok-planner','wowok-auditor','wowok-governance'],SKILLS_HINT_FILE=join(getWowMcpDir(),'skills-hint-asked.json');function projectHasSkills(a){for(const b of PROJECT_SKILL_DIRS){for(const c of PROJECT_SKILL_MARKERS){if(existsSync(join(a,b,c)))return!![];}}return![];}function loadSkillsAsked(){try{if(!existsSync(SKILLS_HINT_FILE))return{};return JSON['parse'](readFileSync(SKILLS_HINT_FILE,'utf8'))??{};}catch{return{};}}function persistSkillsAsked(a){try{const b=loadSkillsAsked();b[a]=!![],mkdirSync(dirname(SKILLS_HINT_FILE),{'recursive':!![]}),writeFileSync(SKILLS_HINT_FILE,JSON['stringify'](b,null,0x2),'utf8');}catch{}}function getProjectSkillsHint(){try{const a=process['cwd']();if(!a||projectHasSkills(a))return null;const b=loadSkillsAsked();if(b[a])return null;return persistSkillsAsked(a),'WoWok\x20skills\x20are\x20not\x20installed\x20in\x20this\x20project.\x20Run\x20`wowok-skills\x20init`\x20'+'here\x20to\x20install\x20them\x20(the\x20MCP\x20works\x20regardless;\x20skills\x20improve\x20AI\x20orchestration).';}catch{return null;}}function formatRecipientLabel(a){if(!a)return'unknown';if(typeof a==='string')return a;const b=classifyRecipient(a);if(!b)return JSON['stringify'](a);if(b['kind']==='submission')return'submitted\x20object\x20slot\x20'+b['identifier']+'\x20(object\x20receipt\x20=\x20owner\x20receipt)';if(b['kind']==='signer')return'Signer\x20(caller\x20of\x20the\x20guard-gated\x20alloc)';const c=b['address'];if(c['length']>0x10)return'Entity('+c['slice'](0x0,0x8)+'...'+c['slice'](-0x4)+')';return'Entity('+c+')';}function formatMistAmount(a){const b=Number(a)/0x3b9aca00;if(b===0x0)return'0\x20WOW';const c=b['toFixed'](0x9)['replace'](/\.?0+$/,'');return c+'\x20WOW\x20('+a['toString']()+'\x20MIST)';}function extractNodesForCheck(a){if(!a?.['node'])return[];if(a['node']['nodes']&&Array['isArray'](a['node']['nodes']))return a['node']['nodes'];return[];}function resolvePermissionRef(a){if(!a?.['object'])return null;if(typeof a['object']==='string')return null;const b=a['object'];if(b['permission']){if(typeof b['permission']==='string')return b['permission'];return null;}return null;}function warnPermissionAutoCreation(a,b,c){const d=a?.['object'];d!==null&&typeof d==='object'&&d['permission']===undefined&&c['push']('PERMISSION\x20AUTO-CREATION:\x20no\x20\x27permission\x27\x20specified\x20in\x20the\x20'+b+'\x20creation\x20payload\x20—\x20a\x20NEW\x20Permission\x20object\x20is\x20created\x20automatically.\x20'+'To\x20reuse\x20an\x20existing\x20Permission\x20(recommended\x20when\x20one\x20owner\x20governs\x20several\x20objects),\x20set\x20object.permission\x20to\x20its\x20address\x20or\x20LocalMark\x20name.');}export async function warnMerchantCompensationFundLow(a,b,c){const d=a?.['object'];if(typeof d!=='string'||!d['trim']())return;let e;try{const r=await query_objects({'objects':[d],'network':b,'no_cache':!![]});e=r?.['objects']?.[0x0];}catch{return;}if(!e||e['type']!=='Service')return;const f=s=>{if(typeof s==='number'&&Number['isFinite'](s)&&s>=0x0)return BigInt(Math['trunc'](s));if(typeof s==='string'&&/^\d+$/['test'](s['trim']()))return BigInt(s['trim']());return undefined;},g=(String(e['type']??e['type_raw']??'')['match'](/<(.+)>$/)??[])[0x1]??'',h=Array['isArray'](e['sales'])?e['sales']:[],i=h['map'](t=>f(t?.['price']))['filter'](s=>s!==undefined),j=f(e['compensation_fund']);if(j===undefined||i['length']===0x0)return;const k=i['reduce']((s,t)=>t>s?t:s);let l=j;const m=a?.['compensation_fund_add']?.['balance'];if(m!=null){const s=f(m);if(s!==undefined)l=j+s;else{if(!g)return;try{const t=await parseAmount(String(m),g,b);l=j+t['smallestUnit'];}catch{return;}}}const n=a?.['compensation_fund_withdraw']!=null;if(n)l=0x0n;const o=0x3n;if(l>=o*k)return undefined;const p=async u=>{try{return g?(await formatChainValue(u,g,b))['display']:u['toString']();}catch{return u['toString']();}},q='Service\x20\x27'+d+'\x27\x20compensation_fund\x20holds\x20'+await p(l)+'\x20(raw\x20'+l+')\x20—\x20below\x20the\x20'+('award\x20ceiling\x20of\x20'+o+'x\x20the\x20highest\x20SKU\x20price\x20=\x20')+(await p(o*k)+'\x20(raw\x20'+o*k+';\x20the\x20highest\x20')+('SKU\x20price\x20itself\x20is\x20'+await p(k)+').\x20A\x20valid\x20')+'arbitration\x20award\x20above\x20the\x20current\x20balance\x20aborts\x20the\x20buyer\x27s\x20payout\x20with\x20code\x2027\x20'+'(E_COMPENSATION_NOT_MATCH);\x20the\x20abort\x20does\x20NOT\x20consume\x20the\x20claim,\x20and\x20the\x20pool\x20is\x20NEVER\x20auto-refilled.';if(a?.['publish']===!![])return c['push']('MERCHANT\x20FUND\x20DISCLOSURE\x20(publish\x20proceeding\x20—\x20per-order\x20coverage\x20is\x20warned\x20at\x20BUY\x20time):\x20'+q+'\x20'+'Each\x20incoming\x20order\x20will\x20be\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount,\x20not\x203x\x20the\x20highest\x20SKU.\x20Top\x20up\x20via\x20'+'service.compensation_fund_add\x20to\x20widen\x20the\x20payout\x20pool\x20—\x20until\x20then\x20awards\x20beyond\x20the\x20fund\x20abort\x20'+'the\x20buyer\x27s\x20claim\x20with\x20code\x2027\x20(the\x20abort\x20does\x20NOT\x20consume\x20the\x20claim)\x20and\x20the\x20merchant\x20wallet\x20'+'is\x20the\x20backstop.'),undefined;return c['push']('MERCHANT\x20FUND\x20REMINDER\x20(operational):\x20'+q+'\x20Top\x20up\x20via\x20'+'service.compensation_fund_add\x20—\x20each\x20incoming\x20order\x20is\x20checked\x20against\x203x\x20ITS\x20OWN\x20amount\x20at\x20buy\x20time,\x20'+'so\x20size\x20the\x20fund\x20for\x20your\x20typical\x20single\x20order\x20(3x\x20covers\x20any\x20single\x20ruling;\x20more\x20only\x20buys\x20headroom\x20'+'for\x20several\x20concurrent\x20claims).'+(n?'\x20NOTE:\x20this\x20call\x20withdraws\x20the\x20fund\x20—\x20buyers\x20lose\x20payout\x20protection\x20entirely.':'')),undefined;}async function resolveStringRef(a){if(typeof a!=='string')return undefined;const b=a['trim']();if(!b)return undefined;if(/^0x[0-9a-fA-F]{1,64}$/['test'](b))return b['toLowerCase']();try{return await GetAccountOrMark_Address(b)??undefined;}catch{return undefined;}}const ADDR_RE=/^0x[0-9a-fA-F]{1,64}$/;async function assertReferencesResolve(a,b){const c=a?.['data'];if(!c||typeof c!=='object')return;const d=b?.['network']?'\x20(network:\x20'+b['network']+')':'';if(typeof c['object']==='string'&&c['object']['trim']()&&!ADDR_RE['test'](c['object']['trim']())){const g=await resolveStringRef(c['object']);if(!g)throw new Error('invalid\x20parameter:object\x20\x27'+c['object']+'\x27\x20not\x20found\x20locally'+d+'\x20—\x20check\x20local_mark_list\x20/\x20account_list,\x20or\x20pass\x20the\x20on-chain\x20object\x20ID');}const e=typeof c['object']==='object'&&c['object']!==null?c['object']:undefined,f=e?.['permission'];if(typeof f==='string'&&f['trim']()&&!ADDR_RE['test'](f['trim']())){const h=await resolveStringRef(f);if(!h)throw new Error('invalid\x20parameter:permission\x20\x27'+f+'\x27\x20not\x20found\x20locally'+d+'\x20—\x20pass\x20the\x20Permission\x27s\x20object\x20ID,\x20register\x20the\x20mark\x20first,\x20or\x20use\x20the\x20object\x20form\x20permission:{name:\x22'+f+'\x22}\x20to\x20CREATE\x20a\x20new\x20Permission');}}async function checkMachinePermissionBeforePublish(a,b){if(a?.['publish']!==!![])return'';const c=extractNodesForCheck(a);if(c['length']===0x0)return'';const d=collectPermissionIndexes(c);if(d['requiredIndexes']['length']===0x0)return'';let e='';if(d['missingRefs']['length']>0x0){e+='WARNING:\x20Some\x20forwards\x20have\x20NEITHER\x20permissionIndex\x20nor\x20namedOperator.\x20'+'These\x20forwards\x20cannot\x20be\x20executed.\x20Add\x20one\x20or\x20the\x20other:\x0a';for(const k of d['missingRefs']){e+='\x20\x20-\x20Node\x20\x22'+k['nodeName']+'\x22,\x20pair\x20prev_node=\x22'+k['prevNode']+'\x22,\x20forward\x20\x22'+k['forwardName']+'\x22\x0a';}e+='\x0a';}const f=resolvePermissionRef(a);if(!f)return d['requiredIndexes']['length']>0x0&&(e+='PRE-PUBLISH\x20REMINDER:\x20This\x20Machine\x20uses\x20'+d['requiredIndexes']['length']+'\x20custom\x20permission\x20index(es):\x20['+d['requiredIndexes']['join'](',\x20')+'].\x20'+'After\x20creating\x20the\x20Permission\x20object,\x20grant\x20entities\x20for\x20each\x20index\x20via\x20'+'permission.op=\x22add\x20perm\x20by\x20index\x22\x20BEFORE\x20publishing\x20the\x20Machine.\x20'+'Otherwise,\x20forwards\x20using\x20these\x20indexes\x20will\x20be\x20un-executable.\x0a'),e;let g=f;if(!f['startsWith']('0x'))try{const l=await LocalMark['Instance']()['get'](f);if(l?.['address'])g=l['address'];else return e+'PRE-PUBLISH:\x20Could\x20not\x20resolve\x20Permission\x20name\x20\x27'+f+'\x27\x20to\x20an\x20address.\x20Ensure\x20the\x20Permission\x20object\x20exists\x20and\x20is\x20marked.\x20'+'Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}catch{return e+'PRE-PUBLISH:\x20Failed\x20to\x20lookup\x20Permission\x20name\x20\x27'+f+'\x27.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}const h=await resolveNetwork(b?.['network']);let i=null;try{const m=await query_objects({'objects':[g],'network':h}),n=m?.['objects']?.[0x0];if(n){i={'address':g,'entity_count':n['entity_count'],'perm_remark':n['perm_remark'],'owner':n['owner']??n['builder'],'admin':n['admin']};try{i['entityPermissions']=await fetchEntityPermissions(g,h);}catch{}}}catch{return e+'PRE-PUBLISH:\x20Failed\x20to\x20query\x20Permission\x20object\x20'+g+'.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';}if(!i)return e+'PRE-PUBLISH:\x20Permission\x20object\x20'+g+'\x20not\x20found\x20on-chain.\x20Required\x20indexes:\x20['+d['requiredIndexes']['join'](',\x20')+']\x0a';const j=checkPermissionAuthorization(d['requiredIndexes'],i);return(!j['allAuthorized']||!j['allVerified'])&&(e+=formatPermissionWarning(j)+'\x0a'),e;}async function detectServiceGuardCircularDependency(a){if(!a||typeof a['object']!=='object'||a['object']===null)return null;const b=a['order_allocators'];if(!b||typeof b!=='object')return null;const c=Array['isArray'](b['allocators'])?b['allocators']:[];if(c['length']===0x0)return null;const d=[],e=new Set();for(const k of c){const l=k?.['guard'];if(typeof l==='string'&&!l['startsWith']('0x')){if(e['has'](l))continue;e['add'](l);try{const m=await LocalMark['Instance']()['get_address'](l);!m&&d['push'](l);}catch{d['push'](l);}}}if(d['length']===0x0)return null;const f=d['map'](n=>'\x27'+n+'\x27')['join'](',\x20'),g=a['object'],h=g['name']??'<service_name>',i=[{'step':0x1,'action':'onchain_operations','operation_type':'service','params':{...a,'order_allocators':null,'publish':![]},'purpose':'Create\x20Service\x20\x27'+h+'\x27\x20WITHOUT\x20order_allocators\x20to\x20establish\x20'+('its\x20LocalMark\x20entry.\x20After\x20this\x20step,\x20the\x20name\x20\x27'+h+'\x27\x20resolves\x20')+'to\x20an\x20on-chain\x20address.'},{'step':0x2,'action':'onchain_operations','operation_type':'guard','params':d['map'](n=>({'object':{'name':n,'type':'Guard'},'_hint':'Table\x20items\x20may\x20reference\x20Service\x20\x27'+h+'\x27\x20by\x20name'})),'purpose':'Create\x20Guard(s)\x20'+f+'.\x20Their\x20table\x20items\x20can\x20now\x20resolve\x20'+('Service\x20\x27'+h+'\x27\x20by\x20name\x20(LocalMark\x20entry\x20from\x20step\x201).')},{'step':0x3,'action':'onchain_operations','operation_type':'service','params':{'object':h,'order_allocators':b,'publish':a['publish']??!![]},'purpose':'Update\x20Service\x20with\x20order_allocators\x20(referencing\x20Guards\x20created\x20in\x20'+'step\x202)\x20and\x20publish.\x20After\x20publish,\x20order_allocators\x20becomes\x20SDK-LOCKED.'}],j='⚠️\x20Circular\x20dependency\x20detected:\x20Service\x20↔\x20Guard\x0a\x0a'+('Cannot\x20create\x20Service\x20with\x20order_allocators\x20referencing\x20non-existent\x20Guard(s):\x20'+f+'.\x0a\x0a')+'Explanation:\x20Guard\x20table\x20items\x20may\x20reference\x20the\x20Service\x20by\x20name,\x20creating\x20a\x20circular\x20'+'dependency:\x20the\x20Service\x20must\x20exist\x20as\x20a\x20LocalMark\x20before\x20the\x20Guard\x20can\x20resolve\x20it,\x20'+'but\x20the\x20Guard\x20must\x20exist\x20before\x20the\x20Service\x20can\x20reference\x20it\x20in\x20order_allocators.\x20'+'The\x20SDK\x20would\x20fail\x20with\x20a\x20BCS\x20serialization\x20error:\x20\x22Expected\x20valid\x20Address\x20for\x20'+'ValueType.Address,\x20but\x20failed\x20to\x20resolve\x20string:\x20<name>\x22.\x0a\x0a'+'Recommended\x20steps:\x0a'+i['map'](n=>'\x20\x20Step\x20'+n['step']+'\x20('+n['operation_type']+'):\x20'+n['purpose'])['join']('\x0a')+'\x0a\x0aHint:\x20This\x20is\x20the\x20canonical\x20Service↔Guard\x20circular\x20dependency.\x20The\x203-step\x20'+'pattern\x20above\x20is\x20the\x20documented\x20solution\x20(see\x20SCHEMA-03\x20/\x20P0-01\x20fix\x20in\x20'+'schema/call/service.ts\x20publish\x20field\x20description).';return{'content':[{'type':'text','text':j}],'structuredContent':{'result':{'type':'error','error':'Cannot\x20create\x20Service\x20with\x20order_allocators\x20referencing\x20non-existent\x20Guard(s):\x20'+f+'.\x20Circular\x20dependency:\x20Service↔Guard.','error_code':'circular_dependency_detected','retryable':!![],'recovery_hint':JSON['stringify'](i),'related_object':h},'message':'Circular\x20dependency\x20detected:\x20Service\x20↔\x20Guard.\x20See\x20recovery_hint\x20for\x20the\x203-step\x20creation\x20pattern.'}};}function buildFundBlockResult(a,b){const c=a['matchErrors']['length']>0x0,d=a['errors']['length']>0x0,e=a['blockingErrors']['some'](k=>k['includes']('TOKEN\x20CHOICE\x20REQUIRED')),f=c&&d?'FUND\x20OPERATION\x20BLOCKED':c?'TOKEN\x20TYPE\x20MISMATCH\x20—\x20operation\x20blocked':e?'TOKEN\x20CHOICE\x20REQUIRED\x20—\x20operation\x20blocked,\x20awaiting\x20user\x20selection':'FUND\x20INPUT\x20BLOCKED\x20—\x20operation\x20blocked',g=c&&d?'fund_blocked':c?'token_type_mismatch':e?'token_choice_required':'fund_input_error',h=c?'\x0a\x0aThe\x20token\x20type\x20of\x20a\x20generic\x20on-chain\x20object\x20(e.g.\x20Treasury<T>,\x20Service<T>)\x20is\x20'+'determined\x20at\x20creation\x20and\x20can\x20NEVER\x20be\x20changed,\x20and\x20monetary\x20input\x20is\x20never\x20'+('processed\x20with\x20unknown\x20token\x20precision.\x20This\x20'+b+'\x20operation\x20was\x20')+'NOT\x20executed.\x20Fix\x20the\x20errors\x20above\x20and\x20re-issue\x20the\x20operation'+(a['objectTokenType']?'\x20(object\x20token\x20type:\x20'+a['objectTokenType']+')':'')+'.':e?'\x0a\x0aMultiple\x20on-chain\x20tokens\x20may\x20legally\x20share\x20the\x20same\x20symbol\x20(several\x20'+'issuers\x20can\x20each\x20publish\x20a\x20\x22USDT\x22),\x20so\x20a\x20bare\x20symbol\x20can\x20never\x20identify\x20'+('the\x20issuer.\x20This\x20'+b+'\x20operation\x20was\x20NOT\x20executed\x20and\x20no\x20')+'on-chain\x20action\x20was\x20taken.\x20Present\x20the\x20numbered\x20candidate\x20list\x20above\x20to\x20'+'the\x20USER,\x20wait\x20for\x20their\x20choice,\x20then\x20re-issue\x20with\x20the\x20chosen\x20token\x27s\x20'+'full\x20type.':'\x0a\x0aMonetary\x20input\x20is\x20never\x20processed\x20with\x20unknown\x20token\x20precision\x20or\x20an\x20'+('unparseable\x20amount.\x20This\x20'+b+'\x20operation\x20was\x20NOT\x20executed\x20and\x20')+'no\x20on-chain\x20action\x20was\x20taken.\x20Follow\x20the\x20recovery\x20steps\x20in\x20the\x20error\x20'+'above\x20and\x20re-issue\x20the\x20operation.',i='⛔\x20'+f+'\x0a\x0a'+a['blockingErrors']['map'](k=>'\x20\x20•\x20'+k)['join']('\x0a')+h,j=e?'Present\x20the\x20numbered\x20token\x20candidate\x20list\x20from\x20the\x20error\x20message\x20to\x20the\x20USER\x20'+'(full\x20type,\x20name,\x20decimals,\x20verified\x20tag\x20are\x20all\x20shown)\x20—\x20do\x20NOT\x20pick\x20an\x20'+'issuer\x20yourself.\x20After\x20the\x20user\x20chooses\x20(by\x20number\x20or\x20by\x20pasting\x20the\x20full\x20'+('type),\x20re-issue\x20this\x20'+b+'\x20operation\x20with\x20that\x20token\x27s\x20FULL\x20type\x20')+'string\x20(package::module::Name)\x20in\x20type_parameter\x20(object.type_parameter\x20for\x20'+'service\x20creation;\x20root\x20type_parameter\x20for\x20payment\x20receive).\x20Also\x20verify\x20the\x20'+'WOW\x20network\x20selection\x20is\x20correct.':'Use\x20token\x20type\x20'+(a['objectTokenType']??'<the\x20object\x27s\x20generic\x20token\x20type>')+'\x20for\x20all\x20'+('amounts,\x20coins,\x20and\x20receive\x20records\x20in\x20this\x20'+b+'\x20operation.\x20')+'Query\x20the\x20object\x20via\x20query_toolkit\x20onchain_objects\x20to\x20confirm\x20its\x20generic\x20'+'token\x20type\x20(type_raw,\x20e.g.\x20\x220x2::treasury::Treasury<0x2::wow::WOW>\x22).\x20'+'For\x20precision-unavailable\x20tokens,\x20retry\x20the\x20operation\x20—\x20the\x20on-chain\x20'+'metadata\x20lookup\x20may\x20have\x20been\x20transient.';return{'content':[{'type':'text','text':i}],'structuredContent':{'result':{'type':'error','error':a['blockingErrors']['join']('\x20|\x20'),'error_code':g,'retryable':!![],'recovery_hint':j},'message':'Fund\x20operation\x20blocked\x20before\x20execution.'}};}async function checkSalesWipNetworkDeployment(a,b,c){const d=a?.['sales'];if(!d||typeof d!=='object')return null;if(d['op']!=='add'&&d['op']!=='set')return null;const e=Array['isArray'](d['sales'])?d['sales']:[];if(e['length']===0x0)return null;const f=b?.['network']==='localnet';for(const g of e){const h=g?.['wip'];if(typeof h!=='string'||h==='')continue;const i=classifyWipPath(h),j=!i['is_local']&&i['is_network']&&!f&&(i['type']==='http_url'||i['type']==='ipfs'&&/^https?:/i['test'](h));if(j){const m=await probeWipReachability(h)['catch'](()=>({'ok':![],'reason':'probe\x20failed'}));if(!m['ok']){const n=m['status']?'HTTP\x20'+m['status']:m['reason']??'unreachable',o='⛔\x20WIP\x20HOST\x20UNREACHABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20but\x20the\x20host\x20is\x20not\x20reachable\x20('+n+').\x0a\x0a')+'Every\x20customer\x20order_new\x20fetches\x20this\x20URL\x20to\x20verify\x20the\x20WIP\x20file\x20—\x20while\x20it\x20is\x20'+'down,\x20ALL\x20purchases\x20on\x20this\x20Service\x20abort\x20100%\x20(F-27:\x20WIP\x20single-host\x20outage\x20'+'famously\x20took\x20every\x20listing\x20down\x20at\x20once).\x0a\x0a'+'This\x20is\x20NOT\x20a\x20wrong-network\x20problem\x20—\x20do\x20NOT\x20switch\x20networks.\x0a\x0a'+'Fix:\x0a'+'\x20\x20•\x20Transient\x20outage:\x20wait\x20for\x20the\x20host\x20to\x20recover,\x20then\x20re-run\x20this\x20operation.\x0a'+'\x20\x20•\x20Permanent:\x20redeploy\x20the\x20.wip\x20file\x20to\x20another\x20public\x20endpoint\x20and\x20update\x20'+'sale.wip\x20+\x20wip_hash\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20site,\x20or\x20wip_file\x20'+'type=\x27upload\x27\x20for\x20the\x20official\x20store).\x0a'+'\x20\x20•\x20Testing\x20only:\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20verification.';return{'content':[{'type':'text','text':o}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20host\x20unreachable\x20('+n+'):\x20'+h+'.\x20Customer\x20order_new\x20would\x20abort\x20100%\x20while\x20the\x20WIP\x20file\x20cannot\x20be\x20fetched\x20(F-27).\x20Not\x20a\x20wrong-network\x20problem.','error_code':'wip_host_unreachable','retryable':!![],'recovery_hint':'Transient\x20outage:\x20retry\x20after\x20the\x20host\x20recovers.\x20Permanent:\x20redeploy\x20the\x20.wip\x20'+'file\x20to\x20another\x20public\x20endpoint\x20and\x20set\x20sale.wip\x20to\x20the\x20new\x20URL\x20(update\x20'+'wip_hash\x20too);\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20host\x20unreachable\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}}if(!i['is_local'])continue;if(i['type']==='local_http'){if(f){c['push']('WIP\x20INTERNAL-TEST-ONLY\x20REMINDER\x20(sale\x20\x22'+g['name']+'\x22):\x20wip\x20=\x20\x22'+h+'\x22\x20is\x20a\x20'+('local-network\x20URL\x20('+i['description']+').\x20It\x20is\x20reachable\x20ONLY\x20on\x20the\x20')+'local\x20machine\x20/\x20LAN\x20where\x20a\x20local\x20WIP\x20server\x20runs.\x20This\x20is\x20acceptable\x20for\x20LOCALNET\x20'+'internal\x20testing,\x20but\x20customers\x20and\x20on-chain\x20verifiers\x20on\x20OTHER\x20machines\x20CANNOT\x20'+'reach\x20it\x20—\x20on\x20testnet/mainnet,\x20every\x20customer\x20order_new\x20would\x20fail\x20100%\x20because\x20the\x20'+'WIP\x20file\x20cannot\x20be\x20verified.\x20For\x20any\x20non-localnet\x20deployment,\x20replace\x20this\x20URL\x20with\x20'+'a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20or\x20leave\x20sale.wip\x20empty.');continue;}const p='a\x20local-network\x20URL\x20('+i['description']+')',q='⛔\x20WIP\x20IS\x20NOT\x20NETWORK-DEPLOYABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20which\x20is\x20'+p+'.\x0a\x0a')+'INTERNAL\x20TEST\x20USE\x20ONLY:\x20this\x20URL\x20is\x20reachable\x20only\x20from\x20the\x20merchant\x27s\x20own\x20machine/LAN.\x20'+'Customers\x20on\x20other\x20machines\x20cannot\x20reach\x20it,\x20so\x20verifying\x20the\x20WIP\x20file\x20at\x20order\x20time\x20'+'fails\x20and\x20order_new\x20aborts\x20100%.\x20Local-network\x20WIP\x20URLs\x20are\x20allowed\x20ONLY\x20for\x20'+('localnet\x20internal\x20testing\x20(env.network\x20=\x20\x22localnet\x22);\x20on\x20'+(b?.['network']??'this\x20network')+'\x20')+'they\x20must\x20never\x20be\x20stored\x20on-chain.\x0a\x0a'+'Fix:\x20deploy\x20the\x20.wip\x20file\x20to\x20a\x20publicly\x20reachable\x20endpoint,\x20then\x20re-run\x20with\x20'+'sale.wip\x20=\x20\x22<public\x20URL>\x22\x20(e.g.\x20GitHub\x20Pages,\x20IPFS\x20gateway,\x20or\x20your\x20own\x20website).\x0a'+'\x20\x20•\x20GitHub\x20Pages:\x20https://<user>.github.io/<repo>/<file>.wip\x0a'+'\x20\x20•\x20IPFS:\x20\x20\x20\x20\x20\x20\x20\x20https://ipfs.io/ipfs/<CID>\x20\x20(or\x20ipfs://<CID>)\x0a'+'\x20\x20•\x20Your\x20site:\x20\x20\x20https://<your-domain>/<path>/<file>.wip\x0a'+'Alternatively,\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20SKIP\x20WIP\x20verification\x20—\x20'+'TESTING\x20ONLY,\x20not\x20recommended\x20for\x20production.';return{'content':[{'type':'text','text':q}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20is\x20'+p+':\x20'+h+'.\x20Local-network\x20URLs\x20are\x20INTERNAL\x20TEST\x20USE\x20ONLY\x20—\x20customers\x20cannot\x20verify\x20them,\x20aborting\x20order_new\x20100%.','error_code':'wip_not_network_deployed','retryable':!![],'recovery_hint':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20'+'and\x20set\x20sale.wip\x20to\x20the\x20public\x20URL;\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20'+'verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20is\x20a\x20local-network\x20URL\x20(INTERNAL\x20TEST\x20USE\x20ONLY)\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}const k='a\x20LOCAL\x20'+i['type']+'\x20path',l='⛔\x20WIP\x20IS\x20NOT\x20NETWORK-DEPLOYABLE\x20—\x20sales\x20NOT\x20submitted\x0a\x0a'+('Sale\x20\x22'+g['name']+'\x22\x20has\x20wip\x20=\x20\x22'+h+'\x22,\x20which\x20is\x20'+k+'.\x0a\x0a')+'Why\x20this\x20is\x20fatal:\x20the\x20WIP\x20path\x20is\x20stored\x20ON-CHAIN\x20and\x20every\x20customer\x20'+'(on\x20a\x20different\x20machine)\x20fetches\x20it\x20when\x20placing\x20an\x20order.\x20A\x20local\x20path\x20/\x20'+'localhost\x20/\x20LAN\x20URL\x20is\x20reachable\x20only\x20from\x20YOUR\x20machine\x20—\x20it\x20passes\x20the\x20'+'merchant-side\x20set-time\x20verification\x20but\x20makes\x20order_new\x20abort\x20100%\x20for\x20customers.\x0a\x0a'+'Fix:\x20deploy\x20the\x20.wip\x20file\x20to\x20a\x20publicly\x20reachable\x20endpoint,\x20then\x20re-run\x20with\x20'+'sale.wip\x20=\x20\x22<public\x20URL>\x22\x20(e.g.\x20GitHub\x20Pages,\x20IPFS\x20gateway,\x20or\x20your\x20own\x20website).\x0a'+'\x20\x20•\x20GitHub\x20Pages:\x20https://<user>.github.io/<repo>/<file>.wip\x0a'+'\x20\x20•\x20IPFS:\x20\x20\x20\x20\x20\x20\x20\x20https://ipfs.io/ipfs/<CID>\x20\x20(or\x20ipfs://<CID>)\x0a'+'\x20\x20•\x20Your\x20site:\x20\x20\x20https://<your-domain>/<path>/<file>.wip\x0a'+'Alternatively,\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20SKIP\x20WIP\x20verification\x20—\x20'+'TESTING\x20ONLY,\x20not\x20recommended\x20for\x20production.';return{'content':[{'type':'text','text':l}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+g['name']+'\x22\x20wip\x20is\x20'+k+':\x20'+h+'.\x20Local\x20WIP\x20paths\x20are\x20unreachable\x20by\x20customers\x20and\x20abort\x20order_new\x20100%.','error_code':'wip_not_network_deployed','retryable':!![],'recovery_hint':'Deploy\x20the\x20.wip\x20file\x20to\x20a\x20public\x20endpoint\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20your\x20own\x20website)\x20'+'and\x20set\x20sale.wip\x20to\x20the\x20public\x20URL;\x20or\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20'+'verification\x20(TESTING\x20ONLY).','related_object':g['name']},'message':'WIP\x20is\x20not\x20network-deployable\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}return null;}function checkSalesZeroPrice(a){const b=a?.['sales'];if(!b||typeof b!=='object')return null;if(b['op']!=='add'&&b['op']!=='set')return null;const c=Array['isArray'](b['sales'])?b['sales']:[];for(const d of c){const e=d?.['price']?.['balance']??d?.['price'],f=typeof e==='string'?e['trim']():String(e??'');if(!/^\d+$/['test'](f)||BigInt(f)!==0x0n)continue;const g='⛔\x20ZERO-PRICE\x20SKU\x20REFUSED\x20—\x20sales\x20NOT\x20submitted\x20(F-BS-76)\x0a\x0a'+('Sale\x20\x22'+d['name']+'\x22\x20has\x20price\x200.\x20A\x20zero-priced\x20SKU\x20is\x20LISTABLE\x20but\x20PERMANENTLY\x20UNBUYABLE:\x20')+'the\x20chain\x20refuses\x20zero-total\x20orders\x20(client\x20order_new_zero_total_dead_order,\x20on-chain\x20abort\x2042),\x20'+'so\x20no\x20buyer\x20can\x20ever\x20purchase\x20it\x20—\x20and\x20the\x20listing\x20is\x20immutable\x20on\x20those\x20points\x20that\x20matter\x20'+'(removing\x20it\x20costs\x20gas;\x20repricing\x20needs\x20a\x20fresh\x20set).\x0a\x0a'+'Fixes\x20(pick\x20one):\x0a'+'\x20\x20•\x20Price\x20it\x20at\x201\x20smallest\x20unit\x20(the\x20minimum\x20buyable\x20price)\x20—\x20the\x20standard\x20way\x20to\x20express\x20a\x20free\x20tier.\x0a'+'\x20\x20•\x20If\x20the\x20item\x20is\x20not\x20actually\x20for\x20sale,\x20do\x20not\x20add\x20it\x20to\x20sales.\x0a'+'\x20\x20•\x20Testing\x20an\x20unbuyable\x20listing\x20deliberately?\x20Re-run\x20with\x20price\x20\x221\x22\x20—\x20the\x20gate\x20arithmetic\x20is\x20identical\x20from\x20price\x201\x20upward.';return{'content':[{'type':'text','text':g}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+d['name']+'\x22\x20price\x200:\x20zero-priced\x20SKUs\x20are\x20permanently\x20unbuyable\x20(zero-total\x20gate,\x20abort\x2042)\x20—\x20F-BS-76.','error_code':'invalid_parameter','retryable':![],'recovery_hint':'Set\x20price\x20to\x20at\x20least\x201\x20smallest\x20unit\x20(a\x20free\x20tier\x20is\x20priced\x20at\x201,\x20not\x200)\x20and\x20resubmit;\x20'+'or\x20drop\x20the\x20item\x20from\x20sales\x20if\x20it\x20is\x20not\x20for\x20sale.','related_object':d['name']},'message':'Zero-price\x20SKU\x20refused\x20—\x20sales\x20not\x20submitted.\x20See\x20recovery_hint.'}};}return null;}function extractObjectOnlyRef(a){const b=a;if(b['submission'])return undefined;const c=b['data'];if(!c||typeof c!=='object'||Array['isArray'](c))return undefined;const d=c,e=Object['keys'](d);if(e['length']!==0x1||e[0x0]!=='object')return undefined;const f=d['object'];return typeof f==='string'&&f['trim']()['length']>0x0?f['trim']():undefined;}async function queryObjectOnlyResult(a,b,c){let d=[],f;try{const j=await query_objects({'objects':[b],'network':c?.['network'],'no_cache':!![]});d=j['objects']??[],d['length']===0x0&&(f='Object\x20\x27'+b+'\x27\x20not\x20found\x20on-chain.\x20It\x20may\x20never\x20have\x20been\x20created,\x20'+'its\x20local\x20mark\x20may\x20be\x20missing\x20(register\x20it\x20via\x20local_mark_operation),\x20'+'or\x20it\x20may\x20live\x20on\x20a\x20different\x20network.');}catch(k){const l=k?.['message']??String(k);f='Query\x20failed\x20for\x20\x27'+b+'\x27:\x20'+l;}const g=d['map'](m=>({...m,'change':'queried'})),h=f?'Object-only\x20payload\x20for\x20'+a+'\x20—\x20nothing\x20to\x20mutate,\x20no\x20transaction\x20was\x20sent\x20(no\x20gas\x20used).\x20'+f:'Object-only\x20payload\x20for\x20'+a+'\x20—\x20nothing\x20to\x20mutate,\x20no\x20transaction\x20was\x20sent\x20(no\x20gas\x20used).\x20Current\x20on-chain\x20state\x20of\x20\x27'+b+'\x27:',i={'message':h,'result':f?{'type':'error','error':f,'error_code':'object_not_found','retryable':![],'recovery_hint':'Check\x20the\x20name\x20spelling\x20(local_mark_operation\x20list),\x20the\x20env.network\x20value,\x20or\x20create\x20the\x20object\x20first.'}:{'type':'data','data':g},'semantic':{'intent':a+'_read','status':f?'failed':'success','summary':h,'next_actions':[{'action':'Use\x20query_toolkit\x20(onchain_objects)\x20for\x20richer\x20inspection\x20—\x20content\x20fields,\x20ownership,\x20dynamic\x20tables.','reason':'Object-only\x20onchain_operations\x20payloads\x20are\x20answered\x20by\x20a\x20pure\x20query;\x20they\x20never\x20mutate\x20on-chain\x20state.','tool':'query_toolkit','priority':'recommended'}],'warnings':['Payload\x20contained\x20only\x20data.object\x20—\x20interpreted\x20as\x20a\x20READ\x20request,\x20not\x20a\x20transaction.']}};return{'content':[{'type':'text','text':h}],'structuredContent':i};}function checkOrderAllocatorsPrePublish(b,c){if(!b||typeof b!=='object')return null;let d,f;try{const h=assessAllocationRisks({'allocators_config':b,'operation_type':'create','trigger_source':'service_order_allocators'}),i=new Set(['R-A-1-01','R-A-1-02','R-A-1-03','R-A-2-03']);d=h['risks']['filter'](j=>i['has'](j['id']))['map'](j=>({'id':j['id'],'title':j['title'],'mitigation':j['mitigation']})),f=h['risks']['filter'](j=>!i['has'](j['id'])&&(j['level']==='critical'||j['level']==='high'))['map'](j=>({'id':j['id'],'title':j['title'],'mitigation':j['mitigation']}));}catch(j){return c['push']('pre-publish\x20allocators\x20risk\x20scan\x20failed\x20(non-blocking):\x20'+(j instanceof Error?j['message']:String(j))+'\x20—\x20'+'run\x20the\x20recipient\x20constraint\x20audit\x20via\x20query_toolkit\x20service_panorama\x20before\x20publish.'),null;}for(const k of f){c['push']('ALLOCATOR\x20RISK\x20'+k['id']+'\x20(advisory\x20—\x20needs\x20full-evidence\x20review\x20before\x20publish):\x20'+k['title']+'\x20—\x20'+k['mitigation']);}try{const l=Array['isArray'](b?.['allocators'])?b['allocators']:[],m=l['map']((n,o)=>{const p=Array['isArray'](n?.['sharing'])?n['sharing']:[];return p['some'](q=>q?.['who']&&typeof q['who']==='object'&&'GuardIdentifier'in q['who'])?o:-0x1;})['filter'](n=>n>=0x0);m['length']>0x0&&c['push']('REFUND\x20TRACK\x20GUARD\x20GATING\x20(advisory):\x20Allocator(s)\x20['+m['join'](',\x20')+']\x20pay\x20a\x20'+'GuardIdentifier\x20recipient\x20—\x20the\x20order-anchored\x20refund\x20track.\x20Verify\x20the\x20bound\x20guard\x20is\x20'+'NODE-GATED:\x20AND[progress.node==<X>]\x20per\x20refundable\x20node\x20(per-node\x20tracks\x20are\x20the\x20'+'default\x20form\x20—\x20a\x20node\x20set\x20is\x20also\x20expressible\x20via\x20the\x20relies\x20two-level\x20tree:\x20'+'OR-subguard\x20per\x20node\x20under\x20an\x20AND\x20parent).\x20A\x20signer==order.owner\x20leg\x20is\x20OPTIONAL\x20here,\x20'+'not\x20a\x20safety\x20requirement:\x20with\x20a\x20GuardIdentifier\x20recipient\x20the\x20payee\x20is\x20already\x20hard-bound\x20to\x20the\x20'+'order\x20(funds\x20land\x20in\x20the\x20order\x20no\x20matter\x20who\x20triggers),\x20so\x20the\x20signer\x20leg\x20only\x20restricts\x20who\x20may\x20'+'fire\x20the\x20trigger\x20—\x20drop\x20it\x20when\x20keepers\x20or\x20the\x20service\x20should\x20be\x20able\x20to\x20trigger\x20refunds.\x20There\x20is\x20'+'NO\x20on-chain\x20seal\x20between\x20the\x20refund\x20track\x20and\x20a\x20compensation\x20ruling\x20—\x20a\x20claim\x20settling\x20does\x20NOT\x20close\x20'+'this\x20track;\x20enforce\x20any\x20refund-vs-compensation\x20exclusion\x20by\x20gating\x20the\x20guard\x20(e.g.\x20on\x20arb/settlement\x20'+'state)\x20at\x20configuration\x20time.\x20Declare\x20the\x20identifier-254\x20once\x20slot\x20on\x20the\x20'+'refund\x20guard\x20(chain\x20derives\x20the\x20key\x20from\x20payment_info.for_object\x20—\x20unwidenable\x20per-order\x20replay\x20'+'protection;\x20reserve\x20identifier\x20255\x20with\x20a\x20period\x20key\x20for\x20rails\x20that\x20legitimately\x20repeat\x20per\x20period)\x20'+'so\x20a\x20consumed\x20claim\x20cannot\x20re-split\x20the\x20residual.');}catch{}if(d['length']===0x0)return null;const g='⛔\x20SERVICE\x20PUBLISH\x20BLOCKED\x20—\x20order_allocators\x20fails\x20the\x20pre-publish\x20risk\x20scan\x20'+'(the\x20allocation\x20rule\x20kernel,\x20same\x20rules\x20as\x20the\x20template\x20scan).\x0a\x0a'+d['map'](n=>'\x20\x20•\x20'+n['id']+':\x20'+n['title']+'\x0a\x20\x20\x20\x20Fix:\x20'+n['mitigation'])['join']('\x0a')+'\x0a\x0aorder_allocators\x20is\x20PERMANENTLY\x20IMMUTABLE\x20after\x20publish\x20(E_ALREADY_PUBLISHED,\x20'+'no\x20pause+lock\x20exception)\x20—\x20a\x20published\x20misconfiguration\x20locks\x20order\x20funds\x20or\x20aborts\x20'+'every\x20alloc()\x20transaction\x20for\x20the\x20lifetime\x20of\x20this\x20Service.\x20Fix\x20the\x20allocator\x20table\x20'+'and\x20re-issue\x20this\x20operation.\x20This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20action\x20was\x20taken.';return{'content':[{'type':'text','text':g}],'structuredContent':{'result':{'type':'error','error':d['map'](n=>n['id']+':\x20'+n['title'])['join']('\x20|\x20'),'error_code':'allocators_risk_blocked','retryable':!![],'recovery_hint':JSON['stringify'](d)},'message':'Service\x20publish\x20blocked\x20by\x20the\x20pre-publish\x20allocators\x20risk\x20scan.'}};}async function checkEntityRecipientGate(a,b,c){let d;try{d=await checkEntityRecipients(a);}catch(i){return c?.['push']('R-RECIPIENT-03\x20recipient\x20gate\x20failed\x20(non-blocking):\x20'+(i instanceof Error?i['message']:String(i))),null;}if(d['length']===0x0)return null;const f=d['filter'](j=>j['severity']==='critical'),g=d['filter'](j=>j['severity']!=='critical');for(const j of g){c?.['push'](formatEntityRecipientViolation(j)+'\x20—\x20fix\x20before\x20committing\x20this\x20allocator\x20table.');}if(f['length']===0x0)return null;const h='⛔\x20OPERATION\x20BLOCKED\x20—\x20'+b+'\x20violates\x20'+ENTITY_RECIPIENT_RULE_ID+'\x20'+'(direct-sales\x20Entity\x20recipient\x20rule).\x0a\x0a'+f['map'](k=>'\x20\x20•\x20'+formatEntityRecipientViolation(k))['join']('\x0a')+(g['length']>0x0?'\x0a\x0aAlso\x20reported\x20(non-blocking):\x0a'+g['map'](k=>'\x20\x20•\x20'+formatEntityRecipientViolation(k))['join']('\x0a'):'')+('\x0a\x0a'+describeEntityRecipients(f)+'\x0a\x0a')+'order_allocators\x20is\x20PERMANENTLY\x20IMMUTABLE\x20after\x20publish\x20(no\x20pause+lock\x20escape)\x20—\x20'+'an\x20empty\x20Entity\x20recipient\x20published\x20now\x20silently\x20pays\x20the\x20builder\x20forever.\x20Fix\x20the\x20'+'recipient\x20table\x20and\x20re-issue\x20this\x20operation.\x20This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20'+'action\x20was\x20taken.';return{'content':[{'type':'text','text':h}],'structuredContent':{'result':{'type':'error','error':f['map'](k=>k['rule_id']+'\x20allocator['+k['allocator_index']+'].sharing['+k['sharing_index']+']:\x20'+k['reason'])['join']('\x20|\x20'),'error_code':'entity_recipient_invalid','retryable':!![],'recovery_hint':describeEntityRecipients(f)},'message':'Operation\x20blocked\x20by\x20'+ENTITY_RECIPIENT_RULE_ID+':\x20an\x20Entity\x20recipient\x20is\x20empty,\x20omitted,\x20or\x20resolves\x20to\x20the\x20deploying\x20account.'}};}function warnAmountEscrowDeadlock(a,b,c){try{const d=Array['isArray'](a?.['allocators'])?a['allocators']:[],e=d['map'](k=>(Array['isArray'](k?.['sharing'])?k['sharing']:[])['filter'](l=>l?.['mode']==='Amount')['reduce']((l,m)=>l+(Number(m?.['sharing']?.['balance'])||0x0),0x0)),f=e['some'](k=>k>0x0);if(!f)return;const g=Array['isArray'](b?.['sales'])?b['sales']:[],h=g['map'](k=>Number(k?.['price']?.['balance']))['filter'](k=>Number['isFinite'](k)&&k>0x0);if(h['length']===0x0)return;const j=h['reduce']((k,l)=>k+l,0x0);for(let k=0x0;k<e['length'];k++){e[k]>j&&c['push']('FIXED-AMOUNT\x20DEADLOCK\x20RISK\x20(advisory):\x20Allocator['+k+']\x20Amount\x20sum='+e[k]+'\x20exceeds\x20the\x20'+('minimum\x20single-order\x20escrow\x20Σ(price×1)='+j+'\x20(sales\x20configured\x20in\x20this\x20call;\x20quantity\x20fixed\x20at\x20buy\x20time).\x20')+'An\x20order\x20smaller\x20than\x20the\x20Amount\x20aborts\x20alloc()\x20with\x20Insufficient\x20balance\x20—\x20if\x20this\x20allocator\x20is\x20the\x20only\x20'+'match\x20on\x20a\x20terminal\x20forward,\x20that\x20order\x27s\x20balance\x20is\x20permanently\x20stranded.\x20Use\x20Rate\x20sharing\x20for\x20'+'penalty/proportional\x20rules\x20(scales\x20with\x20the\x20order),\x20or\x20bound\x20the\x20Amount\x20below\x20the\x20smallest\x20expected\x20order.');}}catch{}}async function checkArbitrationsBeforePublish(a,b,c){if(!Array['isArray'](a)||a['length']===0x0)return null;const d=await resolveNetwork(b?.['network']),e=[],f=[],g=[],h=[];for(const i of a){let j;if(typeof i==='string')j=i['startsWith']('0x')?i:await LocalMark['Instance']()['get_address'](i)['catch'](()=>undefined)??undefined;else{if(i&&typeof i==='object'){const k=i['name']??i['object']??i['address'];typeof k==='string'&&(j=k['startsWith']('0x')?k:await LocalMark['Instance']()['get_address'](k)['catch'](()=>undefined)??undefined);}}if(!j){g['push'](typeof i==='string'?i:JSON['stringify'](i));continue;}try{const l=await query_objects({'objects':[j],'network':d,'no_cache':!![]}),m=l?.['objects']?.[0x0];if(!m||m['type']!=='Arbitration'){g['push'](j);continue;}const n=m['data']??m;if(n['bPaused']===!![])e['push'](j);const o=Array['isArray'](n['voting_guard'])?n['voting_guard']['length']:0x0;if(o===0x0)f['push'](j);const p=typeof n['permission']==='string'?n['permission']:undefined;if(p){const s=await query_objects({'objects':[p],'network':d,'no_cache':!![]}),t=s?.['objects']?.[0x0],u=t?.['data']??t,v=Array['isArray'](u?.['admin'])?u['admin']:[],w=await fetchEntityPermissions(p,d);w['size']===0x0&&h['push'](j+'\x20(admin:\x20'+(v['length']>0x0?v['join'](',\x20'):'unresolved')+')');}}catch{g['push'](j);}}g['length']>0x0&&c['push']('PRE-PUBLISH:\x20Could\x20not\x20resolve/query\x20bound\x20Arbitration(s)\x20['+g['join'](',\x20')+']\x20—\x20'+'verify\x20each\x20is\x20UNPAUSED\x20(new\x20Arbitrations\x20default\x20to\x20bPaused=true;\x20disputes\x20abort\x20with\x20E_PAUSED)\x20'+'and\x20that\x20voting\x20can\x20actually\x20happen:\x20an\x20empty\x20voting_guard\x20means\x20EQUAL\x20vote\x20weight\x20(1\x20person\x201\x20vote),\x20'+'but\x20plain\x20voting\x20still\x20asserts\x20permission\x20358\x20—\x20only\x20the\x20arbitration\x27s\x20bound\x20Permission\x20admin\x20'+'(its\x20creator,\x20by\x20default)\x20and\x20explicit\x20358\x20grantees\x20can\x20vote,\x20so\x20grant\x20358\x20to\x20the\x20disputing\x20'+'parties\x20or\x20configure\x20a\x20voting_guard\x20before\x20relying\x20on\x20a\x20working\x20vote.');f['length']>0x0&&c['push']('C7\x20RISK\x20(concentrated\x20voting):\x20Arbitration(s)\x20['+f['join'](',\x20')+']\x20have\x20an\x20EMPTY\x20voting_guard\x20—\x20'+'this\x20means\x20EQUAL\x20vote\x20weight\x20(1\x20person\x201\x20vote),\x20NOT\x20permissionless.\x20Plain\x20voting\x20asserts\x20'+'permission\x20358\x20on\x20the\x20arbitration\x27s\x20bound\x20Permission,\x20whose\x20admin\x20ALWAYS\x20passes\x20the\x20assert\x20'+'(a\x20fresh\x20Permission\x20seeds\x20its\x20creator\x20as\x20the\x20sole\x20admin;\x20the\x20permission\x20table\x20itself\x20starts\x20empty).\x20'+'So\x20without\x20explicit\x20grants\x20the\x20disputing\x20CUSTOMER\x20can\x20never\x20vote\x20(aborts\x20with\x20code\x205)\x20and\x20every\x20'+'dispute\x20devolves\x20to\x20admin-only\x20voting\x20—\x20the\x20arb\x20admin\x20is\x20both\x20the\x20only\x20voter\x20AND\x20the\x20judge.\x20The\x20'+'service\x20publish\x20gate\x20blocks\x20this\x20shape\x20outright\x20(R-ARB-VOTE-LOCK)\x20when\x20the\x20arb\x20admin\x20also\x20controls\x20'+'the\x20service\x20side;\x20this\x20warning\x20covers\x20the\x20general\x20case.\x20Fix:\x20'+'(1)\x20grant\x20permission\x20358\x20to\x20each\x20disputing\x20party\x20(equal-weight\x20vote\x20among\x20the\x20granted\x20parties),\x20'+'and\x20grant\x20the\x20non-admin\x20operator\x20slots\x20separately\x20—\x20359\x20(ruling)\x20+\x20361\x20(confirm\x20materials)\x20to\x20an\x20'+'EXTERNAL\x20arbitrator,\x20356/357/362-366\x20to\x20any\x20non-admin\x20manager\x20(the\x20creator-admin\x20needs\x20no\x20grants);\x20'+'or\x20(2)\x20for\x20weighted\x20voting,\x20set\x20voting_guard\x20via\x20arbitration\x20voting_guard\x20op=\x22add\x22\x20with\x20'+'a\x20verifier\x20Guard\x20+\x20vote_weight\x20(GuardIdentifier\x20for\x20submitted\x20weights,\x20or\x20FixedValue)\x20—\x20weighted\x20'+'voters\x20then\x20call\x20vote\x20WITH\x20data.vote.voting_guard\x20(plain\x20vote\x20aborts\x20E_VOTING_GUARD_USED\x20once\x20a\x20'+'voting_guard\x20exists;\x20the\x20weighted\x20path\x20authorizes\x20via\x20the\x20guard\x20and\x20does\x20NOT\x20require\x20358).');h['length']>0x0&&c['push']('ADJUDICABILITY\x20RISK\x20(F-34,\x20nnd-tn-261025):\x20bound\x20Arbitration(s)\x20['+h['join'](',\x20')+']\x20hold\x20'+'ZERO\x20adjudication\x20entities\x20on\x20their\x20Permission\x20—\x20the\x20entity\x20table\x20is\x20empty,\x20so\x20NOBODY\x20except\x20the\x20'+'admin\x20can\x20confirm\x20materials,\x20vote,\x20or\x20rule.\x20Disputes\x20can\x20still\x20be\x20FILED\x20(the\x20fee\x20escrows),\x20but\x20'+'there\x20is\x20no\x20on-chain\x20timeout\x20fallback:\x20with\x20an\x20unreachable\x20admin\x20a\x20case\x20stalls\x20forever\x20and\x20the\x20'+'escrowed\x20fee\x20is\x20stranded\x20(nnd-arb\x20live\x20case:\x20a\x20case\x20was\x20filed\x20and\x20paid,\x20no\x20ruling\x20was\x20ever\x20'+'possible).\x20Remedy\x20BEFORE\x20relying\x20on\x20disputes:\x20if\x20the\x20admin\x20account\x20is\x20yours,\x20grant\x20at\x20least\x20one\x20'+'adjudication\x20entity\x20(permission\x20add\x20perm\x20on\x20the\x20arb\x27s\x20Permission:\x20358\x20vote\x20/\x20359\x20ruling\x20/\x20'+'361\x20confirm\x20materials);\x20if\x20the\x20admin\x20is\x20an\x20external\x20third\x20party,\x20confirm\x20they\x20have\x20configured\x20'+'their\x20entity\x20table\x20—\x20otherwise\x20bind\x20an\x20adjudicable\x20arbitration\x20instead.\x20Entities\x20can\x20also\x20be\x20'+'granted\x20after\x20publish,\x20so\x20this\x20is\x20a\x20disclosure,\x20not\x20a\x20blocker\x20—\x20but\x20publishing\x20a\x20Service\x20whose\x20'+'only\x20dispute\x20path\x20is\x20a\x20dead\x20arbitration\x20is\x20a\x20commercial\x20hole\x20buyers\x20inherit.');if(e['length']>0x0){const x='⛔\x20SERVICE\x20PUBLISH\x20BLOCKED\x20—\x20bound\x20Arbitration(s)\x20['+e['join'](',\x20')+']\x20are\x20PAUSED.\x0a\x0a'+'A\x20newly\x20created\x20Arbitration\x20defaults\x20to\x20bPaused=true;\x20while\x20paused,\x20EVERY\x20dispute\x20filing\x20aborts\x20'+'with\x20E_PAUSED\x20—\x20the\x20arbitration\x20mounted\x20on\x20this\x20Service\x20would\x20be\x20decorative\x20(buyers\x20have\x20no\x20'+'working\x20dispute\x20path,\x20and\x20compensation_fund\x20payouts\x20could\x20never\x20be\x20triggered).\x20The\x20on-chain\x20'+'publish\x20check\x20only\x20verifies\x20the\x20arbitrations\x20list\x20is\x20non-empty,\x20NOT\x20that\x20each\x20Arbitration\x20is\x20'+'active\x20—\x20this\x20scan\x20closes\x20that\x20gap.\x0a'+'Fix:\x20issue\x20{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20pause:false}}\x20for\x20each\x20paused\x20'+'Arbitration\x20above,\x20then\x20retry\x20publish=true.\x20This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20action\x20was\x20taken.';return{'content':[{'type':'text','text':x}],'structuredContent':{'result':{'type':'error','error':'arbitration_paused:\x20'+e['join'](',\x20'),'error_code':'arbitrations_paused','retryable':!![],'recovery_hint':JSON['stringify']({'paused':e,'unpaused_hint':'arbitration\x20data:{object,\x20pause:false}'})},'message':'Service\x20publish\x20blocked:\x20bound\x20Arbitration(s)\x20are\x20paused.'}};}return null;}async function checkRefundRecipientSatisfiability(a,b,c){if(!a||typeof a!=='object')return null;const d=Array['isArray'](a?.['allocators'])?a['allocators']:[],e=[];for(let l=0x0;l<d['length'];l++){const m=Array['isArray'](d[l]?.['sharing'])?d[l]['sharing']:[],n=d[l]?.['guard'];if(typeof n!=='string'||n['length']===0x0)continue;for(const o of m){const p=o?.['who'];p&&typeof p==='object'&&'GuardIdentifier'in p&&e['push']({'allocIdx':l,'guardRef':n,'identifier':p['GuardIdentifier']});}}if(e['length']===0x0)return null;const f=await resolveNetwork(b?.['network']),g=[],h=[],j=new Map();for(const r of e){try{let u=j['get'](r['guardRef']);if(u===undefined){let w=r['guardRef'];!w['startsWith']('0x')&&(w=await LocalMark['Instance']()['get_address'](w)['catch'](()=>undefined)??'');if(!w['startsWith']('0x')){h['push'](r['guardRef']);continue;}const x=await query_objects({'objects':[w],'network':f,'no_cache':!![]}),y=x?.['objects']?.[0x0];if(!y||y['type']!=='Guard'){h['push'](r['guardRef']);continue;}u=y['data']??y,j['set'](r['guardRef'],u);}const v=Array['isArray'](u['table'])?u['table']['find'](z=>z?.['identifier']===r['identifier']):undefined;if(!v||v['b_submission']!==!![])continue;pinsIdentifierToSigner(u['root'],r['identifier'])&&g['push']('Allocator['+r['allocIdx']+']\x20guard\x20'+r['guardRef']+'\x20pins\x20recipient\x20identifier\x20'+r['identifier']+'\x20to\x20context(Signer)');}catch{h['push'](r['guardRef']);}}h['length']>0x0&&c['push']('PRE-PUBLISH:\x20could\x20not\x20fetch\x20Guard(s)\x20['+h['join'](',\x20')+']\x20referenced\x20by\x20GuardIdentifier\x20'+'recipient\x20rows\x20—\x20manually\x20verify\x20each\x20refund\x20guard\x20does\x20NOT\x20pin\x20its\x20recipient\x20identifier\x20to\x20'+'context(Signer)\x20(unsatisfiable\x20against\x20the\x20order-anchored\x20escrow:\x20the\x20submission\x20must\x20equal\x20the\x20'+'Order\x20address,\x20never\x20the\x20signer\x20EOA).');if(g['length']===0x0)return null;const k='⛔\x20SERVICE\x20PUBLISH\x20BLOCKED\x20—\x20refund\x20recipient\x20unsatisfiable\x20(GuardIdentifier\x20x\x20for_object\x20x\x20Guard\x20equality).\x0a\x0a'+g['map'](z=>'\x20\x20•\x20'+z)['join']('\x0a')+'\x0a\x0aThe\x20framework-created\x20order\x20escrow\x20anchors\x20PaymentInfo.for_object\x20to\x20the\x20ORDER\x20object\x20address\x20and\x20'+'the\x20chain\x20asserts\x20every\x20GuardIdentifier\x20recipient\x20submission\x20==\x20that\x20address\x20(ERECIPIENT_NOT_FOR_OBJECT,\x20'+'code\x2015).\x20The\x20guard(s)\x20above\x20ALSO\x20require\x20the\x20same\x20submitted\x20value\x20==\x20context(Signer)\x20—\x20an\x20Order\x20address\x20'+'is\x20never\x20the\x20signer\x20EOA,\x20so\x20the\x20allocator\x20can\x20NEVER\x20execute\x20and\x20order\x20funds\x20strand\x20permanently\x20'+'(order_allocators\x20is\x20immutable\x20after\x20publish;\x20test/10\x20T10-10/T10-18\x20stranded\x200.79\x20WOW\x20this\x20way).\x0a'+'Fix\x20(verified\x20ORDER\x20PATTERN,\x20test/10\x20T10-17):\x20keep\x20the\x20recipient\x20GuardIdentifier(n)\x20as-is,\x20and\x20in\x20the\x20'+'GUARD\x20replace\x20logic_equal(context(Signer),\x20identifier[n])\x20with\x20an\x20ORDER\x20FIELD\x20query\x20binding\x20—\x20'+'logic_equal(order.owner,\x20context(Signer))\x20—\x20then\x20submit\x20the\x20ORDER\x20ADDRESS\x20for\x20identifier\x20n.\x20Funds\x20land\x20'+'in\x20the\x20Order\x20object\x20and\x20the\x20buyer\x20withdraws\x20via\x20order\x20receive:\x27recently\x27.\x0a'+'This\x20call\x20was\x20NOT\x20executed\x20and\x20no\x20on-chain\x20action\x20was\x20taken.';return{'content':[{'type':'text','text':k}],'structuredContent':{'result':{'type':'error','error':'refund_recipient_unsatisfiable:\x20'+g['join'](';\x20'),'error_code':'refund_recipient_unsatisfiable','retryable':!![],'recovery_hint':'Rebuild\x20the\x20refund\x20Guard\x20with\x20order.owner==context(Signer)\x20identity\x20binding\x20and\x20submit\x20the\x20Order\x20address\x20for\x20the\x20recipient\x20identifier;\x20then\x20re-issue\x20service\x20publish'},'message':'Service\x20publish\x20blocked:\x20refund\x20recipient\x20guard\x20contradicts\x20the\x20order-anchored\x20escrow\x20binding.'}};}function pinsIdentifierToSigner(a,b){const c=f=>f?.['type']==='context'&&f?.['context']==='Signer',d=f=>f?.['type']==='identifier'&&f?.['identifier']===b,e=f=>{if(!f||typeof f!=='object')return![];if(f['type']==='logic_equal'||f['type']==='logic_as_u256_equal'){const g=Array['isArray'](f['nodes'])?f['nodes']:[];for(let h=0x0;h<g['length'];h++){for(let k=h+0x1;k<g['length'];k++){if(c(g[h])&&d(g[k]))return!![];if(d(g[h])&&c(g[k]))return!![];}}}if(Array['isArray'](f['nodes'])&&f['nodes']['some'](e))return!![];if(f['node']&&e(f['node']))return!![];if(Array['isArray'](f['parameters'])&&f['parameters']['some'](e))return!![];return![];};return e(a);}function describeArbitrationPayload(a){if(Array['isArray'](a))return a['length']+'\x20item(s)';if(a&&typeof a==='object'&&Array['isArray'](a['objects']))return a['objects']['length']+'\x20item(s)';return'<none>';}function canonicalRecipientKey(a){if(typeof a==='string')return a;const b=classifyRecipient(a);if(b?.['kind']==='entity')return'Entity:'+b['address'];if(b?.['kind']==='signer')return'Signer';if(b?.['kind']==='submission')return'GuardIdentifier:'+b['identifier'];return a!=null?JSON['stringify'](a):undefined;}function normHexAddr(b){return b['toLowerCase']()['replace'](/^0x/,'')['padStart'](0x40,'0');}async function describeAllocatorsNotExtensionDiff(a,b,c){try{if(!a||typeof a!=='object')return undefined;const d=a['object']??a['name'],e=typeof d==='string'?/^0x[0-9a-fA-F]{1,64}$/['test'](d)?d:await LocalMark['Instance']()['get_address'](d):undefined;if(!e)return undefined;const f=b,g=Array['isArray'](f?.['allocators'])?f['allocators']:null;if(!g)return undefined;const h=await query_objects({'objects':[e],'network':c}),k=(h?.['objects']??[])['find'](r=>r?.['object']===e),m=k?.['order_allocators'],n=Array['isArray'](m?.['allocators'])?m['allocators']:null;if(!n)return undefined;const o=[],p=readRawOnchainAmount(m?.['threshold']),q=readRawOnchainAmount(f?.['threshold']);p!==undefined&&q!==undefined&&p!==q&&o['push']('threshold\x20mismatch:\x20submitted\x20'+q+'\x20vs\x20live\x20'+p+'\x20(append\x20requires\x20the\x20SAME\x20threshold)');g['length']<n['length']&&o['push']('length\x20mismatch:\x20submitted\x20'+g['length']+'\x20rail(s)\x20vs\x20live\x20'+n['length']+'\x20(append\x20requires\x20length-or-longer\x20with\x20the\x20live\x20prefix\x20preserved)');if(o['length']===0x0){const r=Math['min'](g['length'],n['length']);for(let t=0x0;t<r&&o['length']===0x0;t++){const u=g[t],v=n[t],w=typeof u?.['guard']==='string'?u['guard']:undefined,x=typeof v?.['guard']==='string'?v['guard']:undefined;if(w&&x&&normHexAddr(w)!==normHexAddr(x)){o['push']('rail\x20'+t+'\x20guard\x20rewritten:\x20submitted\x20'+w+'\x20vs\x20live\x20'+x+'\x20(existing\x20allocators\x20must\x20be\x20preserved\x20verbatim\x20as\x20a\x20prefix)');break;}const y=Array['isArray'](u?.['sharing'])?u['sharing']:[],z=Array['isArray'](v?.['sharing'])?v['sharing']:[];if(y['length']!==z['length']){o['push']('rail\x20'+t+'\x20sharing\x20rows:\x20submitted\x20'+y['length']+'\x20vs\x20live\x20'+z['length']);break;}for(let A=0x0;A<Math['min'](y['length'],z['length'])&&o['length']===0x0;A++){const B=canonicalRecipientKey(y[A]?.['who']),C=canonicalRecipientKey(z[A]?.['who']);if(B&&C&&B!==C){o['push']('rail\x20'+t+'\x20row\x20'+A+'\x20recipient\x20rewritten:\x20submitted\x20'+B+'\x20vs\x20live\x20'+C);break;}const D=readRawOnchainAmount(y[A]?.['sharing']),E=readRawOnchainAmount(z[A]?.['sharing']);if(D!==undefined&&E!==undefined&&D!==E){o['push']('rail\x20'+t+'\x20row\x20'+A+'\x20share\x20rewritten:\x20submitted\x20'+D+'\x20vs\x20live\x20'+E);break;}}}}return o['length']===0x0&&o['push']('no\x20field-level\x20divergence\x20found\x20against\x20the\x20live\x20plan\x20—\x20rebuild\x20the\x20payload\x20from\x20the\x20LIVE\x20plan\x20(query_toolkit\x20service_panorama\x20→\x20result.service.order_allocators,\x20authoring\x20form)\x20and\x20re-submit'),'APPEND\x20REJECTED\x20(EALLOCATORS_NOT_EXTENSION):\x20the\x20submitted\x20plan\x20is\x20NOT\x20a\x20pure\x20extension\x20of\x20the\x20live\x20order_allocators.\x20First\x20divergence:\x20'+o['join'](';\x20')+'.\x20'+'Append\x20shape:\x20same\x20threshold,\x20length-or-longer,\x20every\x20existing\x20allocator\x20preserved\x20verbatim\x20as\x20a\x20prefix,\x20new\x20rails\x20appended\x20after.';}catch{return undefined;}}function readRawOnchainAmount(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&/^\d+$/['test'](a['trim']()))return Number(a['trim']());if(a&&typeof a==='object')for(const b of['value','balance','amount']){const c=a[b];if(typeof c==='number'&&Number['isFinite'](c))return c;if(typeof c==='string'&&/^\d+$/['test'](c['trim']()))return Number(c['trim']());}return undefined;}async function expandBareReceiveIds(a,b){const c=a?.['data'];if(!c||typeof c!=='object')return;const d=['receive','owner_receive'],e=[],f=[];for(const l of d){const m=c[l];typeof m==='string'&&/^0x[0-9a-fA-F]{8,}$/['test'](m)&&(e['push'](m),f['push']({'field':l}));}if(e['length']===0x0)return;const g=b??undefined,h=await Config['Instance']()['network_get'](g),j=new WowClient({'url':getFullnodeUrl(h),'network':h}),{objects:k}=await j['core']['getObjects']({'objectIds':e,'include':{'json':!![]}});for(let n=0x0;n<e['length'];n++){const p=f[n]['field'],q=k[n];if(!q||typeof q!=='object'||!q?.['objectId']||!q?.['type'])throw new Error('receive:\x20bare\x20object\x20id\x20\x27'+e[n]+'\x27\x20(field\x20\x27'+p+'\x27)\x20could\x20not\x20be\x20resolved\x20'+('on\x20'+h+'\x20—\x20pass\x20the\x20full\x20received\x20record\x20({id,\x20type,\x20version,\x20digest}),\x20')+'or\x20\x27recently\x27\x20to\x20sweep\x20everything\x20the\x20object\x20received.');c[p]=[{'id':String(q['objectId']),'type':String(q['type']),'content_raw':q['json']??undefined,'version':q['version']!=null?String(q['version']):undefined,'digest':q['digest']!=null?String(q['digest']):undefined}];}}export async function deriveTotalPayIfOmitted(a,b){const c=a?.['order_new']?.['buy'];if(!c)return undefined;if(c['total_pay']!=null){if(c['discount']!=null)return undefined;const e=await catalogTotalWalk(c,a,b)['catch'](()=>null);if(e===null||'error'in e)return undefined;const f=parseTotalPayRaw(c);if(f===undefined||f===e['total'])return undefined;const g=f>e['total']?f-e['total']:e['total']-f;return'total_pay\x20OVERRIDE:\x20explicit\x20'+f+'\x20replaces\x20the\x20catalog\x20derivation\x20'+('Σ\x20price×quantity\x20=\x20'+e['total']+'\x20('+e['lines']['join']('\x20+\x20')+')\x20—\x20drift\x20'+g+'\x20')+(f>e['total']?'ABOVE\x20the\x20catalog\x20total;\x20the\x20excess\x20escrows\x20with\x20the\x20order.\x20Confirm\x20this\x20is\x20intended.':'BELOW\x20the\x20catalog\x20total\x20—\x20without\x20a\x20discount\x20the\x20on-chain\x20quote\x20rejects\x20underpayment\x20(the\x20buy\x20aborts).');}if(c['discount']!=null)throw new Error('buy.total_pay\x20is\x20REQUIRED\x20when\x20a\x20discount\x20is\x20applied\x20—\x20the\x20discounted\x20final\x20total\x20depends\x20on\x20the\x20'+'coupon\x27s\x20live\x20value\x20and\x20must\x20be\x20stated\x20explicitly.\x20Run\x20query_toolkit\x20query_type=\x27service_quote\x27\x20'+'and\x20pass\x20total_pay.balance\x20=\x20the\x20quoted\x20final_total.');const d=await catalogTotalWalk(c,a,b);if('error'in d)throw new Error(d['error']);return c['total_pay']={'balance':d['total']['toString']()},'total_pay\x20auto-derived\x20=\x20'+d['total']['toString']()+'\x20(smallest\x20unit;\x20Σ\x20price×quantity:\x20'+d['lines']['join']('\x20+\x20')+';\x20'+'no\x20discount).\x20Pass\x20total_pay\x20explicitly\x20to\x20pin\x20the\x20amount\x20—\x20REQUIRED\x20when\x20using\x20a\x20discount.';}async function catalogTotalWalk(a,b,c){const d=Array['isArray'](a['items'])?a['items']:[];if(d['length']===0x0)return{'error':'buy.total_pay\x20is\x20omitted\x20and\x20the\x20cart\x20has\x20NO\x20items\x20—\x20there\x20is\x20nothing\x20to\x20derive\x20the\x20payment\x20from'};const e=b?.['object'];if(typeof e!=='string'||e['length']===0x0)return{'error':'buy.total_pay\x20is\x20omitted\x20but\x20the\x20Service\x20reference\x20(data.object)\x20is\x20missing\x20—\x20cannot\x20derive\x20the\x20payment'};const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return{'error':'Service\x20\x27'+e+'\x27\x20could\x20not\x20be\x20resolved\x20—\x20cannot\x20derive\x20total_pay'};const g=await query_serviceContext({'service':f,'network':c}),h=g?.['service'];if(!h)return{'error':'Service\x20\x27'+e+'\x27\x20not\x20found\x20—\x20cannot\x20derive\x20total_pay'};const i=Array['isArray'](h['sales'])?h['sales']:[];let j=0x0n;const k=[];for(const l of d){const m=l?.['name'],n=i['find'](q=>q?.['name']===m);if(!n)return{'error':'cannot\x20derive\x20total_pay:\x20item\x20\x27'+m+'\x27\x20matches\x20NO\x20sale\x20on\x20service\x20\x27'+e+'\x27\x20'+('(available:\x20'+(i['map'](q=>q?.['name'])['filter'](Boolean)['join'](',\x20')||'<none>')+')')};if(n?.['suspension']===!![])return{'error':'cannot\x20derive\x20total_pay:\x20item\x20\x27'+m+'\x27\x20is\x20suspended\x20on\x20service\x20\x27'+e+'\x27'};const o=BigInt(String(n?.['price']?.['balance']??n?.['price']??'0')),p=BigInt(String(l?.['quantity']??l?.['stock']??'1'));if(p<=0x0n)return{'error':'cannot\x20derive\x20total_pay:\x20item\x20\x27'+m+'\x27\x20has\x20non-positive\x20quantity\x20'+p};j+=o*p,k['push'](m+'\x20x'+p+'\x20@\x20'+o);}if(j<=0x0n)return{'error':'derived\x20total_pay\x20would\x20be\x200\x20(all\x20matched\x20sales\x20priced\x200)\x20—\x20pass\x20total_pay\x20explicitly'};return{'total':j,'lines':k};}async function probeOrderNewWipReachability(a,b){const c=a?.['order_new']?.['buy'],d=Array['isArray'](c?.['items'])?c['items']:[];if(d['length']===0x0)return null;const e=a?.['object'];if(typeof e!=='string'||e['length']===0x0)return null;try{const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return null;const g=await query_serviceContext({'service':f,'network':b}),h=Array['isArray'](g?.['service']?.['sales'])?g['service']['sales']:[],i=new Map();for(const j of d){const k=h['find'](o=>o?.['name']===j?.['name']),l=typeof k?.['wip']==='string'?k['wip']:'';if(!l)continue;const m=classifyWipPath(l),n=!m['is_local']&&m['is_network']&&(m['type']==='http_url'||m['type']==='ipfs'&&/^https?:/i['test'](l));if(n)i['set'](String(k['name']??j?.['name']??''),l);}for(const [o,p]of i){const q=await probeWipReachability(p)['catch'](()=>({'ok':![],'reason':'probe\x20failed'}));if(q['ok'])continue;const r=q['status']?'HTTP\x20'+q['status']:q['reason']??'unreachable',s='⛔\x20WIP\x20HOST\x20UNREACHABLE\x20—\x20order\x20NOT\x20created\x20(no\x20money\x20moved)\x0a\x0a'+('The\x20WIP\x20file\x20for\x20sale\x20\x22'+o+'\x22\x20('+p+')\x20is\x20not\x20reachable\x20('+r+').\x20')+'Creating\x20this\x20order\x20would\x20abort\x20100%\x20inside\x20the\x20WIP\x20verification\x20step\x20(F-27:\x20'+'WIP\x20single-host\x20outage\x20—\x20when\x20the\x20host\x20is\x20down,\x20NOBODY\x20can\x20buy\x20from\x20this\x20Service).\x0a\x0a'+'This\x20is\x20NOT\x20a\x20wrong-network\x20problem\x20—\x20do\x20NOT\x20switch\x20networks\x20and\x20do\x20NOT\x20retry\x20blindly.\x0a\x0a'+'Fix:\x0a'+'\x20\x20•\x20Transient\x20outage:\x20retry\x20this\x20order\x20after\x20the\x20host\x20recovers.\x0a'+'\x20\x20•\x20Otherwise:\x20the\x20MERCHANT\x20must\x20redeploy\x20the\x20.wip\x20file\x20to\x20another\x20public\x20endpoint\x20'+'and\x20update\x20sale.wip\x20+\x20wip_hash\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20their\x20own\x20site,\x20or\x20wip_file\x20'+'type=\x27upload\x27\x20for\x20the\x20official\x20store).\x0a'+'\x20\x20•\x20Testing\x20only:\x20the\x20merchant\x20can\x20set\x20sale.wip\x20=\x20\x22\x22\x20(empty)\x20to\x20skip\x20WIP\x20verification.';return{'content':[{'type':'text','text':s}],'structuredContent':{'result':{'type':'error','error':'Sale\x20\x22'+o+'\x22\x20wip\x20host\x20unreachable\x20('+r+'):\x20'+p+'.\x20order_new\x20would\x20abort\x20100%\x20in\x20WIP\x20verification\x20(F-27).\x20Not\x20a\x20wrong-network\x20problem.','error_code':'wip_host_unreachable','retryable':!![],'recovery_hint':'Retry\x20after\x20the\x20host\x20recovers\x20(transient\x20outage),\x20or\x20have\x20the\x20merchant\x20redeploy\x20'+'the\x20.wip\x20file\x20to\x20another\x20public\x20endpoint\x20and\x20update\x20sale.wip\x20+\x20wip_hash.\x20'+'Do\x20NOT\x20switch\x20networks.','related_object':o},'message':'WIP\x20host\x20unreachable\x20—\x20order\x20not\x20created.\x20See\x20recovery_hint.'}};}return null;}catch{return null;}}export async function warnOrderNewFundCoverage(a,b){const c=a?.['order_new']?.['buy'];if(!c)return null;const d=parseTotalPayRaw(c);if(d===undefined)return null;if(d<=0x0n)return null;const e=a?.['object'];if(typeof e!=='string'||e['length']===0x0)return null;try{const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return null;const g=await query_serviceContext({'service':f,'network':b}),h=g?.['service'];if(!h)return null;const i=q=>{if(typeof q==='number'&&Number['isFinite'](q)&&q>=0x0)return BigInt(Math['trunc'](q));if(typeof q==='string'&&/^\d+$/['test'](q['trim']()))return BigInt(q['trim']());if(typeof q==='object'&&q!==null){const r=q?.['balance'];if(typeof r==='string'&&/^\d+$/['test'](r['trim']()))return BigInt(r['trim']());}return undefined;},j=i(h?.['compensation_fund']);if(j===undefined||j<=0x0n)return null;const k=0x3n,l=k*d;if(j>=l)return null;const m=(String(h?.['type']??h?.['type_raw']??'')['match'](/<(.+)>$/)??[])[0x1]??'',n=async q=>{try{return m?(await formatChainValue(q,m,b))['display']:q['toString']();}catch{return q['toString']();}},o=j/k,p=l-j;return'FUND\x20COVERAGE\x20WARNING\x20(compensation_fund_below_order_ceiling)\x20—\x20the\x20buy\x20PROCEEDS,\x20'+'but\x20this\x20Service\x27s\x20compensation\x20pool\x20cannot\x20cover\x20a\x20maximum\x20award\x20on\x20this\x20order.\x0a'+('compensation_fund\x20holds\x20'+await n(j)+'\x20(raw\x20'+j+');\x20the\x20payout\x20requirement\x20for\x20THIS\x20')+('order\x20is\x203x\x20'+await n(d)+'\x20=\x20'+await n(l)+'\x20(raw\x20'+l+')\x20—\x20shortfall\x20')+(await n(p)+'\x20(raw\x20'+p+').\x20Consequence\x20if\x20a\x20ruling\x20awards\x20at\x20the\x20cap:\x20settlement\x20')+'is\x20ALL-OR-NOTHING\x20—\x20the\x20claim\x20aborts\x20with\x20code\x2027\x20(E_COMPENSATION_NOT_MATCH),\x20nothing\x20is\x20paid,\x20'+'the\x20claim\x20is\x20NOT\x20consumed,\x20and\x20the\x20winner\x20retries\x20after\x20the\x20merchant\x20tops\x20up.\x20Standing\x20storefront\x20'+('ceiling:\x20at\x20the\x20current\x20fund\x20the\x20largest\x20fully-covered\x20order\x20amount\x20is\x20'+await n(o)+'\x20')+('(raw\x20'+o+',\x20fund/3).\x0a')+('Fix\x20(merchant):\x20service.compensation_fund_add\x20by\x20'+await n(p)+'\x20to\x20fully\x20cover\x20this\x20')+'basket.\x20Alternative\x20(merchant):\x20run\x20WITHOUT\x20pool\x20protection\x20via\x20service.compensation_fund_withdraw\x20—\x20'+'allowed,\x20but\x20it\x20must\x20be\x20a\x20decision,\x20not\x20an\x20accident.';}catch{return null;}}export async function gateServiceBuyGuardMount(a,b){const c=a?.['buy_guard'];if(typeof c!=='string'||c['trim']()==='')return null;try{const d=c['startsWith']('0x')?c:await LocalMark['Instance']()['get_address'](c)??undefined;if(!d)return null;const e=await batchQueryObjectsByIds([d],b,!![]),f=e?.[0x0];if(!f||f?.['type']!=='Guard')return null;const g=f?.['data']??f,h=Array['isArray'](g?.['table'])?g['table']:[],i=h['some'](k=>Number(k?.['identifier'])===0x0&&k?.['b_submission']===!![]);if(!i)return null;const j='⛔\x20BUY\x20GUARD\x20NOT\x20MOUNTED\x20—\x20this\x20guard\x20can\x20never\x20pass\x20a\x20buy\x20(no\x20state\x20changed)\x0a\x0a'+('Guard\x20\x27'+c+'\x27\x20declares\x20identifier\x200\x20as\x20a\x20SUBMISSION\x20row\x20(b_submission:\x20true).\x20Identifier\x200\x20carries\x20')+'the\x20transacted\x20Order\x20address\x20by\x20protocol\x20convention,\x20and\x20at\x20buy\x20time\x20the\x20order\x20does\x20not\x20exist\x20yet\x20—\x20'+'the\x20purchase\x20verifies\x20the\x20passport\x20BEFORE\x20the\x20order\x20is\x20created,\x20and\x20guard\x20tables\x20are\x20frozen\x20before\x20'+'the\x20call.\x20Mathematically\x20NO\x20passport\x20can\x20satisfy\x20the\x20check,\x20so\x20every\x20buy\x20aborts:\x20the\x20store\x20would\x20be\x20'+'unbuyable\x20while\x20looking\x20open.\x20The\x20chain\x20refuses\x20this\x20mount\x20with\x20code\x2043;\x20this\x20check\x20'+'refuses\x20it\x20here\x20for\x20the\x20same\x20reason.\x0a\x0a'+'Fix:\x20mount\x20a\x20guard\x20that\x20does\x20NOT\x20consume\x20slot\x200.\x20Guards\x20that\x20verify\x20OTHER\x20objects\x20(supply-chain:\x20'+'the\x20buyer\x20submits\x20the\x20MAIN\x20order\x20as\x20evidence)\x20use\x20other\x20slots\x20and\x20stay\x20legal\x20—\x20check\x20the\x20guard\x27s\x20'+'table\x20(query_toolkit\x20query_type=\x27guard_panorama\x27)\x20and\x20remount\x20via\x20service.buy_guard\x20with\x20a\x20compliant\x20guard.';return{'content':[{'type':'text','text':j}],'structuredContent':{'result':{'type':'error','error':'buy_guard\x20\x27'+c+'\x27\x20declares\x20slot\x200\x20as\x20a\x20submission\x20row\x20—\x20a\x20buy\x20can\x20never\x20pass\x20it\x20'+'(slot\x200\x20=\x20the\x20transacted\x20Order\x20address,\x20which\x20does\x20not\x20exist\x20at\x20passport-verify\x20time).','error_code':'buy_guard_order_slot_mount_refused','retryable':!![],'recovery_hint':'Mount\x20a\x20guard\x20whose\x20table\x20does\x20NOT\x20declare\x20identifier\x200\x20as\x20a\x20submission\x20row\x20'+'(b_submission:\x20true).\x20Guards\x20verifying\x20other\x20objects\x20use\x20other\x20slots\x20and\x20stay\x20legal.','related_object':d},'message':'buy_guard\x20not\x20mounted:\x20the\x20guard\x20consumes\x20slot\x200\x20(the\x20transacted\x20Order\x20slot)\x20—\x20no\x20buy\x20could\x20ever\x20pass.\x20See\x20recovery_hint.'}};}catch{return null;}}export function parseTotalPayRaw(a){if(!a)return undefined;const b=c=>{if(typeof c==='string'&&/^\d+$/['test'](c['trim']()))return BigInt(c['trim']());if(typeof c==='number'&&Number['isFinite'](c)&&c>=0x0)return BigInt(Math['trunc'](c));return undefined;};if(typeof a==='object'&&a!==null&&a['total_pay']!==undefined){const c=a['total_pay'];if(typeof c==='object'&&c!==null)return b(c['balance']);return b(c);}return undefined;}export function gateOrderNewZeroTotal(a){const b=a?.['order_new']?.['buy'];if(!b)return null;const c=parseTotalPayRaw(b);if(c===undefined)return null;if(c!==0x0n)return null;const d=typeof a?.['sale']==='string'?a['sale']:undefined,e='⛔\x20ORDER\x20NOT\x20CREATED\x20—\x20the\x20on-chain\x20buy\x20refuses\x20zero-total\x20orders\x20(abort\x2042)\x0a\x0a'+'This\x20buy\x27s\x20total_pay\x20cleared\x20to\x200\x20(100%-off\x20coupon\x20/\x20zero-priced\x20sale'+(d?'\x20on\x20sale\x20\x22'+d+'\x22':'')+').\x20The\x20buy\x20entry\x20asserts\x20total\x20>\x200\x20on-chain\x20'+'(E_ZERO_TOTAL_ORDER,\x20abort\x2042)\x20and\x20rejects\x20the\x20order\x20with\x20a\x20FULL\x20rollback\x20—\x20no\x20order\x20'+'object,\x20no\x20escrow,\x20nothing\x20moves.\x20This\x20client\x20gate\x20mirrors\x20that\x20refusal\x20BEFORE\x20gas\x20is\x20spent.\x0a\x0a'+'Fix\x20(buyer):\x20keep\x20at\x20least\x201\x20raw\x20unit\x20of\x20total_pay\x20—\x20use\x20a\x20smaller\x20coupon\x20so\x20the\x20order\x20total\x20stays\x20'+'above\x20zero,\x20then\x20retry.\x0a'+'Fix\x20(merchant):\x20set\x20a\x20coupon\x20floor\x20so\x20promotions\x20cannot\x20clear\x20the\x20total\x20to\x20zero,\x20and\x20reprice\x20any\x20'+'zero-priced\x20sale\x20to\x20>=\x201\x20raw\x20unit\x20(a\x20zero-priced\x20sale\x20is\x20permanently\x20unbuyable\x20—\x20F-BS-76).\x0a'+'(allow_zero_total\x20does\x20NOT\x20waive\x20the\x20coupon-issuance\x20gate\x20and\x20does\x20NOT\x20unlock\x20a\x20zero-total\x20buy\x20—\x20BSX-F07.)';return{'content':[{'type':'text','text':e}],'structuredContent':{'result':{'type':'error','error':'order\x20total_pay\x20is\x200:\x20the\x20on-chain\x20buy\x20entry\x20refuses\x20zero-total\x20orders\x20(E_ZERO_TOTAL_ORDER,\x20abort\x2042)\x20with\x20full\x20rollback\x20—\x20nothing\x20is\x20created\x20(F-OF2-07\x20/\x20F-azq9-44).','error_code':'order_new_zero_total_dead_order','retryable':![],'recovery_hint':'Buyer:\x20retry\x20with\x20a\x20coupon\x20that\x20leaves\x20total_pay\x20>=\x201\x20raw.\x20Merchant:\x20set\x20a\x20coupon\x20floor\x20on\x20the\x20sale\x20so\x20promotions\x20cannot\x20clear\x20the\x20total\x20to\x20zero,\x20and\x20reprice\x20zero-priced\x20sales\x20to\x20>=\x201\x20raw.','related_object':d},'message':'Order\x20not\x20created:\x20the\x20chain\x20refuses\x20zero-total\x20buys\x20(abort\x2042).\x20See\x20recovery_hint.'}};}const REFUND_TERMINAL_REGEX=/(cancel|return|withdraw|refund|exit|expired)/i;export function minCompletionFixedFloor(a,b){const c=new Map(),d=new Map(),h=[];for(const l of b){const m=String(l?.['name']??'');if(!m)continue;for(const o of Array['isArray'](l?.['pairs'])?l['pairs']:[]){const q=String(o?.['prev_node']??'');let r=c['get'](q);!r&&(r=[],c['set'](q,r));r['push'](m);if(q==='')h['push'](m);let s=d['get'](m);!s&&(s=new Set(),d['set'](m,s));for(const t of Array['isArray'](o?.['forwards'])?o['forwards']:[]){if(typeof t?.['guard']==='string'&&t['guard'])s['add'](t['guard']['toLowerCase']());}}}if(h['length']===0x0)return undefined;const i=[],j=(u,v)=>{if(i['length']>=0x100)return;if(v['includes'](u)){i['push']({'nodes':[...v,u],'cycle':!![]});return;}const w=c['get'](u)??[];if(w['length']===0x0){i['push']({'nodes':[...v,u],'cycle':![]});return;}for(const x of w)j(x,[...v,u]);};for(const u of h)j(u,[]);if(i['length']===0x0)return undefined;let k;for(const v of i){if(!v['cycle']&&REFUND_TERMINAL_REGEX['test'](v['nodes'][v['nodes']['length']-0x1]??''))continue;const w=new Set();for(const y of v['nodes']){for(const z of d['get'](y)??[])w['add'](z);}let x=0x0n;for(const A of a){if(A['guard']&&w['has'](A['guard']))x+=A['sum'];}if(k===undefined||x<k)k=x;}return k;}export const KEEPER_DUAL_PAYOUT_DIRECTIVE='KEEPER\x20DIRECTIVE\x20(automation):\x20this\x20refusal\x20is\x20a\x20HARD\x20STOP.\x20(1)\x20Never\x20retry\x20this\x20call\x20unchanged\x20—\x20'+'the\x20gate\x20re-fires\x20on\x20the\x20same\x20on-chain\x20facts\x20every\x20time.\x20(2)\x20NEVER\x20set\x20acknowledge_dual_payout\x20yourself\x20'+'to\x20push\x20the\x20call\x20through\x20—\x20the\x20flag\x20is\x20the\x20HUMAN\x20operator\x27s\x20netting\x20decision,\x20not\x20an\x20automation\x20input,\x20and\x20'+'since\x20D-1\x20it\x20is\x20honored\x20ONLY\x20when\x20the\x20store\x20already\x20carries\x20a\x20human-recorded\x20preauthorization\x20'+'(config_operation\x20store_dual_payout_get\x20shows\x20preauthorized=true).\x20(3)\x20End\x20this\x20keeper\x20step\x20for\x20this\x20order\x20'+'and\x20escalate\x20to\x20the\x20human\x20operator,\x20attaching\x20this\x20refusal\x20plus\x20the\x20facts\x20it\x20names\x20(order\x20address,\x20arb\x20case,\x20'+'claimed_by,\x20indemnity,\x20escrow\x20balance).\x20The\x20human\x20operator\x20then\x20either\x20(a)\x20records\x20the\x20store-level\x20'+'preauthorization\x20ONCE\x20via\x20config_operation\x20store_dual_payout_set\x20{account,\x20confirm:true}\x20—\x20the\x20merchant\x27s\x20'+'standing\x20netting\x20decision\x20—\x20and\x20the\x20same\x20call\x20with\x20acknowledge_dual_payout:true\x20then\x20proceeds,\x20or\x20(b)\x20cancels\x20'+'the\x20step.\x20Retrying\x20in\x20a\x20loop\x20wastes\x20gas;\x20exiting\x20silently\x20strands\x20the\x20payout.';export async function storeDualPayoutVerdict(a){const b=typeof a?.['account']==='string'?a['account']['trim']():'';if(b==='')return{'account':undefined,'authorized':![]};let c;if(/^0x[0-9a-fA-F]{64}$/['test'](b))c=b['toLowerCase']();else try{const e=await LocalMark['Instance']()['get_address'](b)['catch'](()=>undefined)??undefined;c=typeof e==='string'&&/^0x[0-9a-fA-F]{64}$/['test'](e)?e['toLowerCase']():undefined;}catch{}if(!c||!isDualPayoutPreauthorized(c))return{'account':c,'authorized':![]};const d=getStoreDualPayoutPolicy(c);return{'account':c,'authorized':d?.['preauthorized']===!![],...d?.['authorized_at']?{'authorized_at':d['authorized_at']}:{}};}export function arbClaimEscrowEmptyDualPayout(a){const {orderAmount:b,escrowBalance:c,poolValue:d,acknowledged:e}=a;if(b===undefined||b<=0x0)return null;if(c!==0x0)return null;if(d!==undefined&&d<=0x0)return null;return e?'acknowledged':'refuse';}export async function gateOrderNewAmountLegCoverage(b,c){const d=b?.['order_new']?.['buy'];if(!d)return null;const e=parseTotalPayRaw(d);if(e===undefined)return null;if(e<=0x0n)return null;const f=b?.['object'];if(typeof f!=='string'||f['length']===0x0)return null;try{const g=f['startsWith']('0x')?f:await LocalMark['Instance']()['get_address'](f)??undefined;if(!g)return null;const h=await query_objects({'objects':[g],'network':c}),i=(h?.['objects']??[])['find'](o=>o?.['object']===g||o?.['type']==='Service');if(!i||i['type']!=='Service')return null;const j=i?.['order_allocators'],k=Array['isArray'](j?.['allocators'])?j['allocators']:null;if(!k)return null;const l=[];for(const o of k){const p=Array['isArray'](o?.['sharing'])?o['sharing']:[];let q=0x0n;for(const s of p){const t=typeof s?.['sharing']==='string'&&/^\d+$/['test'](s['sharing']['trim']())?BigInt(s['sharing']['trim']()):undefined;if(s?.['mode']===0x0&&t!==undefined)q+=t;}if(q>0x0n)l['push']({'guard':String(o?.['guard']??'')['toLowerCase'](),'sum':q});}if(l['length']===0x0)return null;let m;try{const u=i?.['machine']??i?.['data']?.['machine'];if(typeof u==='string'&&u['length']>0x0){const v=await fetchMachineNodes(String(u),c,![]);m=minCompletionFixedFloor(l,Array['isArray'](v)?v:[]);}}catch{m=undefined;}if(m===undefined)return null;if(e>=m)return null;const n='⛔\x20ORDER\x20NOT\x20CREATED\x20—\x20the\x20escrow\x20can\x20never\x20cover\x20this\x20Service\x27s\x20fixed\x20settlement\x20legs\x20(no\x20money\x20moved)\x0a\x0a'+('Service\x20\x27'+f+'\x27\x20order_allocators\x20carry\x20fixed-Amount\x20legs\x20totalling\x20'+m+'\x20(raw)\x20on\x20EVERY\x20')+'completion\x20route,\x20'+('but\x20THIS\x20order\x20anchors\x20only\x20'+e+'\x20(raw).\x20allocation.move\x20asserts\x20balance\x20>=\x20leg\x20at\x20every\x20')+'fixed-leg\x20fire,\x20so\x20a\x20release\x20would\x20abort\x20EINSUFFICIENT_BALANCE\x20and\x20the\x20order\x20would\x20deadlock\x20'+'mid-journey\x20with\x20money\x20already\x20escrowed.\x0a\x0a'+'Fix:\x0a'+('\x20\x20•\x20Buyer:\x20pay\x20the\x20full\x20listed\x20price\x20(order\x20amount\x20>=\x20'+m+'\x20raw)\x20—\x20partial/discounted\x20amounts\x20')+'cannot\x20complete\x20this\x20Service\x27s\x20staged\x20releases.\x0a'+'\x20\x20•\x20Merchant:\x20to\x20sell\x20at\x20a\x20lower\x20price,\x20reprice\x20the\x20SKUs\x20(sales\x20price)\x20—\x20the\x20fixed\x20legs\x20are\x20'+'immutable\x20after\x20publish\x20(order_allocators\x20append-only),\x20so\x20the\x20LEGS\x20define\x20the\x20floor,\x20not\x20the\x20sticker.';return{'content':[{'type':'text','text':n}],'structuredContent':{'result':{'type':'error','error':'Fixed-Amount\x20settlement\x20legs\x20total\x20'+m+'\x20raw\x20on\x20every\x20completion\x20route\x20but\x20the\x20order\x20anchors\x20'+e+'\x20raw\x20—\x20a\x20release\x20would\x20abort\x20EINSUFFICIENT_BALANCE\x20and\x20deadlock\x20the\x20order\x20mid-journey.','error_code':'order_below_fixed_leg_sum','retryable':!![],'recovery_hint':'Pay\x20at\x20least\x20the\x20fixed-leg\x20total,\x20or\x20have\x20the\x20merchant\x20reprice\x20the\x20SKUs.\x20The\x20legs\x20are\x20'+'immutable\x20after\x20publish\x20(order_allocators\x20append-only)\x20—\x20they\x20define\x20the\x20price\x20floor.','related_object':g},'message':'Order\x20not\x20created:\x20the\x20order\x20amount\x20is\x20below\x20the\x20Service\x27s\x20fixed\x20settlement-leg\x20total.\x20See\x20recovery_hint.'}};}catch{return null;}}const SALE_ITEM_OPS=new Set(['price_add','price_reduce','stock_add','stock_reduce','sale_suspension']);function salePriceRaw(a){const b=a?.['price']?.['balance']??a?.['price'];if(typeof b==='string'&&/^\d+$/['test'](b['trim']()))return BigInt(b['trim']());if(typeof b==='number'&&Number['isFinite'](b)&&b>=0x0)return BigInt(Math['trunc'](b));return undefined;}function saleStockRaw(a){const b=a?.['stock'];if(typeof b==='string'&&/^\d+$/['test'](b['trim']()))return BigInt(b['trim']());if(typeof b==='number'&&Number['isFinite'](b)&&b>=0x0)return BigInt(Math['trunc'](b));return undefined;}export async function prepareSaleItemOp(a,b){const c=a?.['sales']?.['op'],d=typeof c==='string'&&SALE_ITEM_OPS['has'](c)?c:a?.['restock']?.['op']==='flag'?'restock_flag':undefined;if(!d)return null;const e=d==='restock_flag'?a?.['restock']?.['sale_name']:a?.['sales']?.['sale_name'];if(typeof e!=='string'||e['length']===0x0)return null;const f=a?.['object'];if(typeof f!=='string'||f['length']===0x0)return null;try{const g=f['startsWith']('0x')?f:await LocalMark['Instance']()['get_address'](f)??undefined;if(!g)return null;const h=await query_serviceContext({'service':g,'network':b}),i=Array['isArray'](h?.['service']?.['sales'])?h['service']['sales']:[],j=i['find'](k=>typeof k?.['name']==='string'&&k['name']===e);if(!j){const k=i['map'](o=>String(o?.['name']??''))['filter'](o=>o['length']>0x0),l=e['trim']()['toLowerCase'](),m=k['find'](o=>o['trim']()['toLowerCase']()===l),n='⛔\x20SALE\x20OP\x20NOT\x20SENT\x20—\x20unknown\x20sale_name\x20(no\x20money\x20moved,\x20no\x20gas\x20spent)\x0a\x0a'+('\x22'+d+'\x22\x20names\x20sale\x20\x22'+e+'\x22,\x20which\x20does\x20NOT\x20exist\x20on\x20service\x20\x27'+f+'\x27.\x20')+'On-chain\x20this\x20op\x20would\x20abort\x20(code\x2032)\x20after\x20burning\x20gas\x20—\x20the\x20MCP\x20refuses\x20it\x20here\x20instead.\x0a\x0a'+('Available\x20sales:\x20'+(k['length']>0x0?k['map'](o=>'\x22'+o+'\x22')['join'](',\x20'):'<none>')+'\x0a')+(m?'Did\x20you\x20mean\x20\x22'+m+'\x22?\x0a':'')+'Fix:\x20copy\x20the\x20sale_name\x20EXACTLY\x20from\x20the\x20live\x20sales\x20list\x20(query_toolkit\x20/\x20service\x20context),\x20then\x20retry.';return{'block':{'content':[{'type':'text','text':n}],'structuredContent':{'result':{'type':'error','error':'sale_name\x20\x22'+e+'\x22\x20matches\x20no\x20sale\x20on\x20service\x20\x27'+f+'\x27;\x20the\x20on-chain\x20op\x20would\x20abort\x20with\x20code\x2032.\x20'+('Available\x20sales:\x20'+(k['length']>0x0?k['map'](o=>'\x22'+o+'\x22')['join'](',\x20'):'<none>')+'.')+(m?'\x20Did\x20you\x20mean\x20\x22'+m+'\x22?':''),'error_code':'sale_item_op_unknown_sale_name','retryable':!![],'recovery_hint':'Copy\x20the\x20sale_name\x20exactly\x20from\x20the\x20live\x20sales\x20list'+(m?'\x20(did\x20you\x20mean\x20\x22'+m+'\x22?)':'')+',\x20then\x20retry.','related_object':g},'message':'Sale\x20op\x20not\x20sent:\x20unknown\x20sale_name.\x20See\x20recovery_hint.'}}};}return{'prep':{'op':d,'saleName':e,'before':{'price':salePriceRaw(j),'stock':saleStockRaw(j),'suspension':typeof j?.['suspension']==='boolean'?j['suspension']:undefined,'restock':typeof j?.['restock_on_refund']==='boolean'?j['restock_on_refund']:undefined}}};}catch{return null;}}export async function prepareRestockOrderOp(a,b){if(a?.['restock']?.['op']!=='order')return null;const c=a?.['restock']?.['order'],d=a?.['object'];if(typeof c!=='string'||c['length']===0x0)return null;if(typeof d!=='string'||d['length']===0x0)return null;try{const [e,f]=await Promise['all']([d['startsWith']('0x')?Promise['resolve'](d):LocalMark['Instance']()['get_address'](d),c['startsWith']('0x')?Promise['resolve'](c):LocalMark['Instance']()['get_address'](c)]),g=normAddr(e),h=normAddr(f);if(!g||!h)return null;const i=await batchQueryObjectsByIds([h],b,!![]),j=normAddr(rootOf(i[0x0])['service']);if(i['length']>0x0&&j!==undefined&&j!==g){const l='⛔\x20RESTOCK\x20NOT\x20SENT\x20—\x20foreign\x20order\x20(no\x20money\x20moved,\x20no\x20gas\x20spent)\x0a\x0a'+('restock\x20op:\x27order\x27\x20targets\x20order\x20\x27'+c+'\x27,\x20which\x20belongs\x20to\x20service\x20')+('\x27'+j+'\x27,\x20NOT\x20\x27'+d+'\x27.\x20On-chain\x20this\x20call\x20would\x20abort\x20(code\x2026)\x20')+'after\x20burning\x20gas\x20—\x20the\x20MCP\x20refuses\x20it\x20here\x20instead.\x0a\x0a'+'Why:\x20restock\x20is\x20ownership-bound\x20—\x20only\x20an\x20order\x20of\x20THIS\x20service\x20can\x20put\x20its\x20units\x20'+'back\x20on\x20this\x20storefront\x20(a\x20merchant\x20feeding\x20any\x20visible\x20order\x20into\x20its\x20own\x20store\x20'+'would\x20inflate\x20stock).\x0a'+'Fix:\x20run\x20the\x20restock\x20against\x20the\x20order\x27s\x20OWN\x20service.';return{'content':[{'type':'text','text':l}],'structuredContent':{'result':{'type':'error','error':'order\x20\x27'+c+'\x27\x20belongs\x20to\x20service\x20\x27'+j+'\x27,\x20not\x20\x27'+d+'\x27;\x20the\x20on-chain\x20restock\x20would\x20abort\x20with\x20code\x2026.','error_code':'restock_order_foreign_service','retryable':![],'recovery_hint':'Run\x20restock\x20op:\x27order\x27\x20against\x20the\x20service\x20the\x20order\x20was\x20placed\x20on\x20(the\x20order\x27s\x20service\x20binding).','related_object':g},'message':'Restock\x20not\x20sent:\x20foreign\x20order.\x20See\x20recovery_hint.'}};}const k=await batchReadAddressKeyedFields(g,[h],b,!![]);if(k['has'](h)){const m='⛔\x20RESTOCK\x20NOT\x20SENT\x20—\x20already\x20applied\x20(no\x20money\x20moved,\x20no\x20gas\x20spent)\x0a\x0a'+('The\x20purchased\x20units\x20of\x20order\x20\x27'+c+'\x27\x20were\x20ALREADY\x20put\x20back\x20on\x20the\x20shelf\x20of\x20')+('\x27'+d+'\x27\x20—\x20restock\x20is\x20once-per-order,\x20and\x20a\x20second\x20call\x20would\x20stack\x20the\x20')+'quantity\x20again.\x20On-chain\x20this\x20call\x20would\x20abort\x20(code\x2049)\x20after\x20burning\x20gas;\x20the\x20'+'MCP\x20refuses\x20it\x20here\x20instead.\x0a\x0a'+'No\x20retry\x20will\x20succeed\x20—\x20the\x20stock\x20restoration\x20for\x20this\x20order\x20is\x20complete.\x20'+'Query\x20the\x20item\x27s\x20current\x20stock\x20to\x20confirm\x20the\x20units\x20are\x20back.';return{'content':[{'type':'text','text':m}],'structuredContent':{'result':{'type':'error','error':'order\x20\x27'+c+'\x27\x20was\x20already\x20restocked\x20on\x20\x27'+d+'\x27;\x20restock\x20is\x20once-per-order\x20and\x20the\x20on-chain\x20replay\x20would\x20abort\x20with\x20code\x2049.','error_code':'restock_order_already_applied','retryable':![],'recovery_hint':'No\x20retry\x20will\x20succeed\x20—\x20the\x20restoration\x20is\x20already\x20complete.\x20Check\x20the\x20sale\x20item\x27s\x20stock\x20to\x20confirm.','related_object':g},'message':'Restock\x20not\x20sent:\x20already\x20applied\x20for\x20this\x20order.\x20See\x20recovery_hint.'}};}return null;}catch{return null;}}export async function emitSaleItemOpReadback(a,b,c,d){try{const e=b?.['object'];if(typeof e!=='string'||e['length']===0x0)return;const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return;const g=await query_serviceContext({'service':f,'network':c}),h=Array['isArray'](g?.['service']?.['sales'])?g['service']['sales']:[],i=h['find'](p=>typeof p?.['name']==='string'&&p['name']===a['saleName']);if(!i){d['push']('SALE\x20OP\x20READ-BACK:\x20\x22'+a['op']+'\x22\x20on\x20\x22'+a['saleName']+'\x22\x20—\x20the\x20sale\x20is\x20GONE\x20from\x20the\x20live\x20list\x20after\x20the\x20tx\x20'+'(removed\x20concurrently?).\x20Verify\x20with\x20query_toolkit\x20before\x20relying\x20on\x20it.');return;}const j={'price':salePriceRaw(i),'stock':saleStockRaw(i),'suspension':typeof i?.['suspension']==='boolean'?i['suspension']:undefined,'restock':typeof i?.['restock_on_refund']==='boolean'?i['restock_on_refund']:undefined},k=a['op']==='sale_suspension'?'suspension':a['op']==='restock_flag'?'restock':a['op']['startsWith']('price')?'price':'stock',l=p=>p===undefined?'<unreadable>':p['toString'](),m=p=>p===undefined?'<unreadable>':String(p),n=k==='price'?'price:\x20'+l(a['before']['price'])+'\x20→\x20'+l(j['price'])+'\x20(raw)':k==='stock'?'stock:\x20'+l(a['before']['stock'])+'\x20→\x20'+l(j['stock'])+'\x20(units)':k==='restock'?'restock_on_refund:\x20'+m(a['before']['restock'])+'\x20→\x20'+m(j['restock']):'suspension:\x20'+m(a['before']['suspension'])+'\x20→\x20'+m(j['suspension']),o=k==='price'?a['before']['price']!==undefined&&j['price']!==undefined&&a['before']['price']!==j['price']:k==='stock'?a['before']['stock']!==undefined&&j['stock']!==undefined&&a['before']['stock']!==j['stock']:k==='restock'?a['before']['restock']!==undefined&&j['restock']!==undefined&&a['before']['restock']!==j['restock']:a['before']['suspension']!==undefined&&j['suspension']!==undefined&&a['before']['suspension']!==j['suspension'];d['push'](o?'SALE\x20OP\x20READ-BACK:\x20\x22'+a['op']+'\x22\x20landed\x20on\x20\x22'+a['saleName']+'\x22\x20—\x20'+n+'.':'SALE\x20OP\x20READ-BACK:\x20\x22'+a['op']+'\x22\x20on\x20\x22'+a['saleName']+'\x22\x20left\x20the\x20target\x20field\x20UNCHANGED\x20('+n+')\x20—\x20'+'a\x20saturated\x20stock\x20reduce\x20or\x20a\x20same-value\x20write;\x20confirm\x20this\x20is\x20intended.');}catch{}}async function emitMachineNodeReadback(a,b,c,d,e,f,g){const h=e?.['digest'];if(typeof h!=='string'||!h)return;const i=ResponseData(e)['filter'](q=>typeof q?.['type_raw']==='string'&&q['type_raw']['includes']('::machine::Machine')),j=i['filter'](q=>q?.['change']==='created'&&typeof q?.['object']==='string'),k=i['filter'](q=>q?.['change']==='mutated'&&typeof q?.['object']==='string'),l=j[0x0]?.['object']??k[0x0]?.['object'];if(j['length']>0x0&&a){const q=recordMachineCreation(a,j[0x0]['object']);if(q['length']>0x0){const r=q[q['length']-0x1];g['push']('MACHINE\x20FORK\x20(chunked-publish\x20split-brain,\x20gf29\x20F-16):\x20this\x20call\x20CREATED\x20Machine\x20'+j[0x0]['object']+'\x20'+('but\x20\x22'+r['label']+'\x22\x20already\x20created\x20Machine\x20'+r['address']+'\x20earlier\x20in\x20this\x20session\x20')+('('+q['length']+'\x20prior\x20creation(s)\x20under\x20this\x20ref).\x20An\x20unresolvable\x20object\x20ref\x20means\x20CREATE\x20on-chain\x20—\x20')+'a\x20chunked\x20publish\x20that\x20re-sends\x20the\x20same\x20{name}\x20ref\x20forks\x20again\x20per\x20chunk,\x20and\x20the\x20Service\x20binds\x20'+'whichever\x20machine\x20you\x20point\x20it\x20at\x20while\x20the\x20others\x27\x20nodes\x20are\x20orphaned.\x20Every\x20continuation\x20chunk\x20'+'must\x20reference\x20the\x20machine\x20ADDRESS\x20(0x...),\x20or\x20carry\x20the\x20full\x20node\x20set\x20in\x20ONE\x20call.\x20Before\x20going\x20'+'further:\x20query\x20both\x20machines,\x20keep\x20the\x20one\x20holding\x20the\x20complete\x20node\x20set,\x20and\x20bind\x20THAT\x20address.');}}if(!l)return;const m=Array['isArray'](d)?d['map'](s=>s&&typeof s==='object'&&typeof s['name']==='string'?s['name']:'')['filter'](Boolean):[];if(m['length']===0x0&&b['beforeCount']===undefined)return;let n;try{n=(await fetchMachineNodes(l,f,!![]))['map'](s=>s['name']);}catch{return;}if(n['length']===0x0)return;const o=b['beforeCount']!==undefined?'nodes\x20'+b['beforeCount']+'\x20→\x20'+n['length']:'nodes\x20now\x20'+n['length'];if(c==='remove'){const s=m['filter'](t=>n['includes'](t));m['length']>0x0&&s['length']>0x0&&g['push']('MACHINE\x20NODE\x20READ-BACK\x20(gf29\x20F-16):\x20PARTIAL\x20REMOVE\x20—\x20machine\x20'+l+'\x20('+o+')\x20still\x20holds\x20'+('['+s['join'](',\x20')+']\x20after\x20this\x20remove.\x20Re-read\x20before\x20concluding\x20(index\x20lag\x20is\x20possible)\x20')+'and\x20re-send\x20the\x20missing\x20removes\x20referencing\x20the\x20machine\x20ADDRESS.');return;}const p=m['filter'](t=>!n['includes'](t));if(m['length']>0x0&&p['length']>0x0)g['push']('MACHINE\x20NODE\x20READ-BACK\x20(gf29\x20F-16):\x20PARTIAL\x20WRITE\x20—\x20machine\x20'+l+'\x20holds\x20'+n['length']+'\x20node(s)\x20'+('('+o+')\x20but\x20this\x20payload\x27s\x20node(s)\x20['+p['join'](',\x20')+']\x20are\x20NOT\x20in\x20the\x20live\x20table.\x20The\x20chunk\x20')+'did\x20not\x20fully\x20land\x20(index\x20lag\x20is\x20possible\x20—\x20re-read\x20before\x20concluding);\x20verify\x20with\x20query_toolkit\x20and\x20'+'re-send\x20ONLY\x20the\x20missing\x20nodes\x20referencing\x20the\x20machine\x20ADDRESS\x20before\x20publish/bind.');else m['length']>0x0&&g['push']('MACHINE\x20NODE\x20READ-BACK\x20(gf29\x20F-16):\x20machine\x20'+l+'\x20holds\x20'+n['length']+'\x20node(s)\x20('+o+')\x20—\x20'+('all\x20'+m['length']+'\x20node\x20name(s)\x20from\x20this\x20payload\x20verified\x20present\x20in\x20the\x20live\x20table.'));}export async function prepareSalesAddDuplicateGate(a,b,c){if(a?.['sales']?.['op']!=='add')return null;if(c?.['confirmed']===!![])return null;const d=Array['isArray'](a?.['sales']?.['sales'])?a['sales']['sales']:[];if(d['length']===0x0)return null;const e=a?.['object'];if(typeof e!=='string'||e['length']===0x0)return null;try{const f=e['startsWith']('0x')?e:await LocalMark['Instance']()['get_address'](e)??undefined;if(!f)return null;const g=await query_serviceContext({'service':f,'network':b}),h=Array['isArray'](g?.['service']?.['sales'])?g['service']['sales']:[],i=new Map();for(const p of h){if(typeof p?.['name']==='string')i['set'](p['name'],p);}const j=d['filter'](q=>typeof q?.['name']==='string'&&i['has'](q['name']));if(j['length']===0x0)return null;const k=q=>{const r=q?.['balance']??q;if(typeof r==='string'&&/^\d+$/['test'](r['trim']()))return r['trim']();if(typeof r==='number'&&Number['isFinite'](r)&&r>=0x0)return String(Math['trunc'](r));return'<unset>';},l=(q,r)=>{const t=saleStockRaw(q),u=saleStockRaw({'stock':r?.['stock']});return t!==undefined&&u!==undefined&&u<t;},m=j['map'](q=>{const r=i['get'](q['name']),t=l(r,q);return'\x20\x20•\x20\x22'+q['name']+'\x22\x0a'+('\x20\x20\x20\x20\x20\x20price:\x20\x20\x20\x20\x20\x20'+k(r?.['price'])+'\x20→\x20'+k(q?.['price'])+'\x20(raw\x20units)\x0a')+('\x20\x20\x20\x20\x20\x20stock:\x20\x20\x20\x20\x20\x20'+k(r?.['stock'])+'\x20→\x20'+k(q?.['stock'])+'\x20(units)')+(t?'\x20\x20⚠️\x20STOCK\x20LOSS\x20—\x20the\x20new\x20value\x20REPLACES\x20the\x20remaining\x20inventory':'')+'\x0a'+('\x20\x20\x20\x20\x20\x20suspension:\x20'+String(r?.['suspension']??'<unset>')+'\x20→\x20'+String(q?.['suspension']??'<unset>')+'\x0a')+'\x20\x20\x20\x20\x20\x20wip/wip_hash:\x20also\x20replaced\x20by\x20the\x20incoming\x20values';}),n=j['some'](q=>l(i['get'](q['name']),q)),o='⏸\x20SALES\x20ADD\x20HELD\x20FOR\x20CONFIRMATION\x20—\x20same-name\x20overwrite\x20(nothing\x20sent\x20yet)\x0a\x0a'+('op:add\x20on\x20service\x20\x27'+e+'\x27\x20re-declares\x20'+j['length']+'\x20existing\x20product\x20name(s).\x20')+'On-chain\x20this\x20is\x20a\x20FULL\x20ROW\x20REPLACEMENT\x20(an\x20exact\x20name\x20match\x20replaces\x20the\x20entire\x20stored\x20row\x20with\x20the\x20incoming\x20sale)\x20—\x20'+'price,\x20stock,\x20suspension\x20and\x20the\x20wip\x20binding\x20all\x20take\x20the\x20NEW\x20values;\x20it\x20is\x20NOT\x20an\x20append.\x0a\x0a'+(m['join']('\x0a')+'\x0a\x0a')+(n?'⚠️\x20At\x20least\x20one\x20product\x27s\x20remaining\x20stock\x20would\x20DROP\x20—\x20buyers\x20mid-purchase\x20can\x20hit\x20an\x20abort\x20when\x20stock\x20runs\x20out.\x0a\x0a':'')+'If\x20the\x20overwrite\x20is\x20INTENDED,\x20re-send\x20the\x20SAME\x20call\x20with\x20env.confirmed=true\x20and\x20it\x20will\x20proceed\x20as\x20declared.\x0a'+'If\x20not,\x20rename\x20the\x20incoming\x20product(s)\x20or\x20use\x20the\x20per-item\x20ops\x20(price_add\x20/\x20stock_add\x20/\x20sale_suspension)\x20to\x20change\x20one\x20field.';return{'content':[{'type':'text','text':o}],'structuredContent':{'outcome':'pending_input','message':o,'result':{'type':'pending_confirmation','preview':{'operation_type':'service_sales_add','duplicates':j['map'](q=>{const r=i['get'](q['name']);return{'sale_name':q['name'],'before':{'price':k(r?.['price']),'stock':k(r?.['stock']),'suspension':r?.['suspension']},'after':{'price':k(q?.['price']),'stock':k(q?.['stock']),'suspension':q?.['suspension']},'stock_loss':l(r,q)};})},'rule_id':'sales_add_same_name_replace'},'semantic':{'intent':'service_sales_add_awaiting_confirmation','status':'pending_input','summary':'sales\x20op:add\x20would\x20OVERWRITE\x20'+j['length']+'\x20existing\x20product(s)\x20(full\x20row\x20replacement\x20incl.\x20stock).\x20NOT\x20executed.\x20Re-send\x20with\x20env.confirmed=true\x20to\x20proceed,\x20or\x20rename\x20/\x20use\x20per-item\x20ops.','next_actions':[{'action':'confirm:\x20re-send\x20the\x20SAME\x20sales\x20op:add\x20with\x20env.confirmed=true','reason':'The\x20same-name\x20overwrite\x20is\x20intended;\x20review\x20the\x20diff\x20above\x20before\x20confirming.','tool':'onchain_operations','priority':'required'},{'action':'alternative:\x20rename\x20incoming\x20products\x20or\x20use\x20per-item\x20ops\x20(price_add\x20/\x20stock_add\x20/\x20stock_reduce\x20/\x20sale_suspension)','reason':'Per-item\x20ops\x20change\x20one\x20field\x20without\x20replacing\x20the\x20row.','tool':'onchain_operations','priority':'optional'}],'warnings':n?['At\x20least\x20one\x20product\x27s\x20remaining\x20stock\x20would\x20drop\x20under\x20the\x20incoming\x20values.']:[]}}};}catch{return null;}}export function gateServicePublishPreflight(a){if(a?.['publish']!==!![])return null;const b=a?.['creation_plan'];if(b==null)return null;const c=(h,i,j)=>({'content':[{'type':'text','text':'⛔\x20SERVICE\x20NOT\x20PUBLISHED\x20—\x20'+i+'\x0a\x0a'+j}],'structuredContent':{'result':{'type':'error','error':i,'error_code':h,'retryable':!![],'recovery_hint':j},'message':'Service\x20not\x20published:\x20the\x20creation_plan\x20gate\x20rejected\x20the\x20publish.\x20See\x20recovery_hint.'}});if(typeof b!=='object'||Array['isArray'](b)||!Array['isArray'](b['steps']))return c('creation_plan_malformed','creation_plan\x20is\x20present\x20but\x20malformed\x20(expected\x20the\x20merchant_guide\x20Plan\x20JSON\x20with\x20a\x20steps\x20array).','Pass\x20the\x20plan\x20object\x20EXACTLY\x20as\x20merchant_guide\x20delivered\x20it\x20(its\x20creation_plan\x20field),\x20or\x20omit\x20'+'creation_plan\x20entirely\x20to\x20publish\x20the\x20manual\x20way.\x20Do\x20not\x20hand-edit\x20the\x20plan.');const d=b,f=d['steps']['filter'](h=>h?.['op']==='publish');if(f['length']===0x0)return c('creation_plan_malformed','creation_plan\x20carries\x20no\x20publish\x20step\x20—\x20it\x20is\x20not\x20the\x20plan\x20merchant_guide\x20handed\x20out\x20for\x20this\x20build.','Pass\x20the\x20plan\x20object\x20EXACTLY\x20as\x20merchant_guide\x20delivered\x20it\x20(its\x20creation_plan\x20field),\x20or\x20omit\x20'+'creation_plan\x20entirely\x20to\x20publish\x20the\x20manual\x20way.');const g=typeof a?.['object']==='string'?a['object']:a?.['object']?.['name'];if(typeof g==='string'&&g['length']>0x0&&!g['startsWith']('0x')){const h=f['map'](i=>{const j=i?.['target']?.['$ref'],k=typeof j==='string'?d['steps']['find'](m=>m['id']===j):undefined,l=k?.['op']==='create'&&typeof k['params']?.['name']==='string'?k['params']['name']:undefined;return typeof l==='string'&&!l['startsWith']('0x')?l:undefined;})['filter'](i=>typeof i==='string'&&i['length']>0x0);if(h['length']>0x0&&!h['includes'](g))return c('creation_plan_target_mismatch','creation_plan\x27s\x20publish\x20step(s)\x20target\x20'+h['map'](i=>'\x27'+i+'\x27')['join'](',\x20')+'\x20'+('but\x20this\x20call\x20operates\x20on\x20\x27'+g+'\x27\x20—\x20the\x20plan\x20does\x20not\x20describe\x20this\x20Service.'),'Publish\x20the\x20Service\x20named\x20in\x20the\x20plan,\x20or\x20go\x20back\x20to\x20merchant_guide\x20and\x20rebuild\x20the\x20plan\x20for\x20'+'this\x20Service.\x20Never\x20attach\x20another\x20build\x27s\x20plan\x20to\x20a\x20publish\x20call.');}try{const {plan:i,audit:j}=preflightPlan(d),k=j['issues']['length']===0x0&&!j['findings']['some'](m=>m['level']==='critical'),l=[];for(const m of i['steps']){if(m['op']!=='publish')continue;for(const n of m['preflight']){if(n['status']==='fail')l['push'](m['id']+':\x20'+n['check']);}}if(!k||l['length']>0x0){const o=j['findings']['filter'](r=>r['level']==='critical'||l['some'](t=>t['endsWith'](r['rule_id'])))['slice'](0x0,0x8)['map'](r=>'\x20\x20•\x20['+r['level']+']\x20'+r['rule_id']+':\x20'+r['title']+'\x20—\x20'+r['description']+(r['mitigation']?'\x20Fix:\x20'+r['mitigation']:'')),p=j['issues']['slice'](0x0,0x5)['map'](r=>'\x20\x20•\x20['+r['code']+']'+(r['step']?'\x20(step\x20'+r['step']+')':'')+'\x20'+r['detail']),q=(p['length']>0x0?'Structural\x20issues:\x0a'+p['join']('\x0a')+'\x0a':'')+(o['length']>0x0?'Audit\x20findings:\x0a'+o['join']('\x0a')+'\x0a':'')+(l['length']>0x0?'Failed\x20freeze\x20gates:\x20'+l['join'](';\x20')+'.':'');return c('creation_plan_preflight_failed','the\x20creation_plan\x20freeze\x20matrix\x20has\x20failed\x20gates\x20—\x20publishing\x20it\x20would\x20go\x20live\x20against\x20a\x20plan\x20'+'merchant_guide\x27s\x20audit\x20rejected:\x0a'+q,'Fix\x20the\x20plan\x20and\x20re-run\x20merchant_guide\x20(the\x20audit\x20findings\x20above\x20name\x20the\x20rule\x20and\x20the\x20fix),\x20'+'then\x20pass\x20the\x20NEW\x20plan\x20back\x20here.\x20Do\x20not\x20publish\x20with\x20failed\x20gates:\x20order_allocators\x20and\x20the\x20'+'machine\x20binding\x20are\x20immutable\x20after\x20publish.');}return null;}catch(r){return c('creation_plan_malformed','creation_plan\x20could\x20not\x20be\x20audited\x20('+(r['message']??String(r))+').','Pass\x20the\x20plan\x20object\x20EXACTLY\x20as\x20merchant_guide\x20delivered\x20it,\x20or\x20omit\x20creation_plan\x20entirely\x20to\x20'+'publish\x20the\x20manual\x20way.');}}async function applyInitialForwardAfterOrderNew(a,b){const c=a?.['object'];if(typeof c!=='string'||c['length']===0x0)return undefined;if(b?.['dry_run']===!![])return undefined;try{const d=c['startsWith']('0x')?c:await LocalMark['Instance']()['get_address'](c)??undefined;if(!d)return undefined;const g=await query_objects({'objects':[d],'network':b?.['network'],'no_cache':!![]}),h=g?.['objects']?.[0x0]?.['data']??g?.['objects']?.[0x0],i=typeof h?.['progress']==='string'?h['progress']:undefined;if(!i)return undefined;const j=await query_objects({'objects':[i],'network':b?.['network'],'no_cache':!![]}),k=j?.['objects']?.[0x0]?.['data']??j?.['objects']?.[0x0],l=typeof k?.['machine']==='string'?k['machine']:undefined;if(!l)return undefined;const m=await fetchMachineNodes(l,b?.['network'],![]),o=[];for(const u of m){for(const v of u['pairs']){if(v['prev_node']!=='')continue;for(const w of v['forwards']){if(!w['name'])continue;o['push']({'forward':w,'target':u['name'],'threshold':v['threshold']});}}}if(o['length']===0x0)return undefined;const r=o['map'](x=>'\x22'+x['forward']['name']+'\x22\x20→\x20\x22'+x['target']+'\x22'+(x['forward']['guard']?'\x20[guarded]':''))['join'](';\x20'),s='onchain_operations\x20{\x20operation_type:\x20\x27progress\x27,\x20data:\x20{\x20object:\x20\x27'+i+'\x27,\x20'+('task:\x20\x27'+d+'\x27,\x20operate:\x20{\x20op:\x20\x27next\x27,\x20operation:\x20{\x20forward:\x20\x27<entry\x20forward>\x27,\x20')+'next_node_name:\x20\x27<target>\x27\x20}\x20}\x20}\x20}',t=o['length']===0x1&&!o[0x0]['forward']['guard']&&o[0x0]['forward']['namedOperator']===''&&o[0x0]['forward']['weight']>=o[0x0]['threshold'];if(t){const x=new CallProgress({'object':i,'task':d,'operate':{'op':'next','operation':{'forward':o[0x0]['forward']['name'],'next_node_name':o[0x0]['target']}}}),y=await x['call'](b),z=!!y&&typeof y==='object'&&y?.['effects']?.['status']?.['status']==='success';if(z)return'INITIAL\x20FORWARD\x20AUTO-APPLIED:\x20\x22'+o[0x0]['forward']['name']+'\x22\x20→\x20\x22'+o[0x0]['target']+'\x22\x20'+('(digest\x20'+(y?.['digest']??'n/a')+').\x20The\x20order\x20is\x20OPEN\x20for\x20business\x20—\x20the\x20')+'workflow\x20has\x20started,\x20counterparties\x20can\x20see\x20and\x20act\x20on\x20it\x20now.';const A=y&&typeof y==='object'?String(y?.['effects']?.['status']?.['error']??y?.['error']??'unknown\x20rejection'):'unknown\x20rejection';return'PENDING\x20INITIAL\x20FORWARD\x20(auto-apply\x20was\x20REJECTED,\x20funds\x20are\x20SAFE):\x20the\x20order\x20is\x20funded\x20but\x20'+('still\x20at\x20the\x20empty\x20entry\x20state\x20—\x20the\x20workflow\x20has\x20NOT\x20started.\x20Entry\x20forward:\x20'+r+'.\x20')+('Rejection:\x20'+A['slice'](0x0,0x12c)+'.\x20Apply\x20it\x20manually\x20once\x20the\x20cause\x20is\x20fixed:\x20'+s);}return'PENDING\x20INITIAL\x20FORWARD:\x20the\x20order\x20is\x20funded\x20but\x20still\x20at\x20the\x20empty\x20entry\x20state\x20—\x20the\x20workflow\x20'+('has\x20NOT\x20started\x20(abnb7\x20F37).\x20Entry\x20forward(s):\x20'+r+'.\x20This\x20MCP\x20auto-applies\x20only\x20an\x20')+('unguarded\x20single-forward\x20holder\x20entry;\x20this\x20entry\x20needs\x20a\x20manual\x20call:\x20'+s);}catch(B){return'PENDING\x20INITIAL\x20FORWARD\x20(auto-apply\x20probe\x20failed:\x20'+String(B?.['message']??B)['slice'](0x0,0xc8)+'):\x20the\x20'+'order\x20may\x20still\x20be\x20at\x20the\x20empty\x20entry\x20state\x20—\x20check\x20the\x20Progress\x27s\x20current\x20node\x20and\x20apply\x20the\x20'+'entry\x20forward\x20if\x20the\x20workflow\x20has\x20not\x20started\x20(query\x20the\x20order,\x20then\x20progress\x20operate\x20\x27next\x27).';}}async function snapshotProgressNodePreAdvance(a,b){try{if(b?.['dry_run']===!![])return undefined;const c=a?.['operate'];if(!c||c['op']!=='next')return undefined;const d=a?.['object'];if(typeof d!=='string'||d['length']===0x0)return undefined;const e=d['startsWith']('0x')?d:await LocalMark['Instance']()['get_address'](d)??undefined;if(!e)return undefined;const f=await query_objects({'objects':[e],'network':b?.['network'],'no_cache':!![]}),g=f?.['objects']?.[0x0]?.['data']??f?.['objects']?.[0x0],h=typeof g?.['current']==='string'?g['current']:undefined;if(h===undefined)return undefined;const i=typeof g?.['machine']==='string'?g['machine']:undefined;return{'progressAddr':e,'preNode':h,'machineAddr':i};}catch{return undefined;}}async function annotateProgressAdvanceOutcome(a,b,c,d){try{if(!b||!a)return;const e=extractProgressEventNodeFromTx(c,b['progressAddr']);if(e!==undefined&&e!==b['preNode'])return;const f=async()=>{const s=await query_objects({'objects':[b['progressAddr']],'network':d?.['network'],'no_cache':!![]});return s?.['objects']?.[0x0]?.['data']??s?.['objects']?.[0x0];};let g=await f();const h=extractObjectVersionFromTx(c,b['progressAddr']);for(let s=0x0;h!==undefined&&g&&String(g?.['version']??'')!==h&&s<0x2;s++){await new Promise(t=>setTimeout(t,0x258)),g=await f();}if(!g||h!==undefined&&String(g?.['version']??'')!==h)return;const i=typeof g?.['current']==='string'?g['current']:undefined;if(i===undefined||i!==b['preNode'])return;let j='unavailable\x20(machine\x20topology\x20read\x20failed)',k;if(b['machineAddr']){const t=await fetchMachineNodes(b['machineAddr'],d?.['network'],![]),u=[];for(const v of t){for(const w of v['pairs']){if(w['prev_node']!==b['preNode'])continue;if(k===undefined)k=w['threshold'];const x=w['forwards']['filter'](y=>!!y['name'])['map'](y=>'\x22'+y['name']+'\x22'+(y['guard']?'\x20[guarded]':'\x20[unguarded]'))['join'](',\x20');if(x)u['push']('→\x20\x22'+v['name']+'\x22\x20(threshold\x20'+w['threshold']+'):\x20'+x);}}if(u['length']>0x0)j=u['join'](';\x20');}const l=Array['isArray'](g?.['session'])?g['session']['slice'](-0x1)[0x0]:undefined,m=l&&Array['isArray'](l['forwards'])?l['forwards']['length']:undefined,o=typeof l?.['weights']==='number'?l['weights']:undefined,q=[];q['push']('ADVANCED:\x20false\x20—\x20the\x20transaction\x20succeeded\x20but\x20the\x20Progress\x20node\x20did\x20NOT\x20move;\x20it\x20is\x20still\x20\x22'+b['preNode']+'\x22.'),q['push']('Outgoing\x20edges\x20from\x20\x22'+b['preNode']+'\x22:\x20'+j+'.');const r=[];if(k!==undefined)r['push']('pair\x20threshold\x20'+k);if(m!==undefined)r['push'](m+'\x20forward\x20submission(s)\x20recorded\x20this\x20session\x20(COUNT,\x20not\x20weight)');if(o!==undefined)r['push']('accumulated\x20weight\x20'+o);if(r['length']>0x0)q['push']('Session:\x20'+r['join'](';\x20')+'.');q['push']('Threshold\x20not\x20met\x20—\x20more\x20submissions/weight\x20needed;\x20funds\x20and\x20state\x20unchanged.');Array['isArray'](a['content'])&&a['content']['push']({'type':'text','text':q['join']('\x20')});try{const y=a['structuredContent'];if(y&&typeof y==='object'){if(!y['semantic']||typeof y['semantic']!=='object')y['semantic']={};y['semantic']['forward_outcome']={'advanced':![],'current_node':b['preNode'],...k!==undefined?{'threshold':k}:{},...m!==undefined?{'session_submission_count':m}:{},...o!==undefined?{'accumulated_weight':o}:{}};}}catch{}}catch{}}function orderOwnerAddr(a){const b=a,c=b?.['builder']??b?.['owner'];if(typeof c==='string'&&c['startsWith']('0x'))return c;const d=c;if(d&&typeof d==='object'){if(typeof d['AddressOwner']==='string')return d['AddressOwner'];if(typeof d['ObjectOwner']==='string')return d['ObjectOwner'];}return undefined;}async function verifyOrderNewLanded(a,b){const c=lastInFlightMarker('order_new',b);if(!c)return undefined;try{const d=await query_events({'type':'NewOrderEvent','order':'descending','limit':0x32,'network':a,'no_cache':!![]});for(const e of d?.['data']??[]){if(e?.['type']!=='NewOrderEvent')continue;const f=matchOrderLandedEvent(c,{'order':e['order'],'progress':e['progress'],'service':e['service'],'sender':e['sender'],'time':e['time'],'digest':e?.['id']?.['txDigest']??e?.['id']?.['tx_digest']});if(f)return f;}}catch{}if(!c['service'])return undefined;try{const g=a,h=await fetchServiceOrders(c['service'],g,!![]),j=(h?.['items']??[])['filter'](p=>typeof p?.['who']==='string'&&p['who']['startsWith']('0x'))['slice'](-0x19);if(j['length']===0x0)return undefined;const k=await batchQueryObjectsByIds(j['map'](p=>p['who']),g,!![])['catch'](()=>[]),l=new Map();for(const p of k){p&&p['type']===ObjectType['Order']&&typeof p['object']==='string'&&l['set'](p['object']['toLowerCase'](),p);}let m,n=0x0;for(const q of j){const r=l['get'](q['who']['toLowerCase']()),s=matchRecentOrder(c,{'order':q['who'],'owner':r?orderOwnerAddr(r):undefined,'time':q['time']});s&&(m=s,n++);}if(!m)return undefined;return n>0x1?m+'\x20('+n+'\x20candidates\x20inside\x20the\x20adoption\x20window\x20—\x20verify\x20items/amount\x20against\x20THIS\x20call\x27s\x20payload\x20before\x20adopting)':m;}catch{return undefined;}}const resolvedNameCache=new Map();export function invalidateResolvedNameCache(){resolvedNameCache['clear']();}async function resolveNamedObjectsInPlace(a){if(!a||typeof a!=='object')return;const b=['object','machine','arb','arbitration_object','permission','contact','um','required_info'],c=['objects','repositories','allocators','guards','items','entities','agents'],d=async e=>{if(typeof e!=='string')return e;const f=e['trim']();if(f===''||f['startsWith']('0x'))return e;const g=resolvedNameCache['get'](f);if(g)return g;try{const h=await LocalMark['Instance']()['get_address'](f);if(h)return resolvedNameCache['set'](f,h),h;return e;}catch{return e;}};for(const e of b){if(!(e in a))continue;a[e]=await d(a[e]);}for(const f of c){const g=a[f];if(!Array['isArray'](g))continue;for(let h=0x0;h<g['length'];h++){const j=g[h];if(j&&typeof j==='object'){for(const k of b){if(k in j)j[k]=await d(j[k]);}if(typeof j['name']==='string'&&!('type_parameter'in j)&&!('permission'in j)){const l=await d(j['name']);if(l!==j['name'])g[h]=l;}}else g[h]=await d(j);}}}async function collectArbitrationRefsForPublish(a,b){const c=a?.['arbitrations'];if(c&&typeof c==='object'&&(c['op']==='add'||c['op']==='set')&&Array['isArray'](c['objects'])&&c['objects']['length']>0x0)return c['objects'];const d=typeof a?.['object']==='string'?a['object']:undefined;if(d)try{const e=d['startsWith']('0x')?d:await LocalMark['Instance']()['get_address'](d)['catch'](()=>undefined)??undefined;if(e){const f=await resolveNetwork(b?.['network']),g=await query_objects({'objects':[e],'network':f,'no_cache':!![]}),h=g?.['objects']?.[0x0];if(h&&h['type']==='Service'){const i=h['data']??h;if(Array['isArray'](i['arbitrations']))return i['arbitrations'];}}}catch{}return[];}async function checkMachineBindingForPublish(a,b){const c=a?.['machine']??undefined,d=typeof c==='string'&&c['trim']()!==''?c['trim']():c&&typeof c==='object'&&typeof c['name']==='string'&&c['name']?c['name']:undefined,e=async h=>{const i=h['startsWith']('0x')?h:await LocalMark['Instance']()['get_address'](h)['catch'](()=>undefined)??undefined;if(!i)return undefined;const j=await resolveNetwork(b?.['network']),k=await query_objects({'objects':[i],'network':j,'no_cache':!![]}),l=k?.['objects']?.[0x0];return l?l['data']??l:undefined;};if(d){const h=await e(d)['catch'](()=>undefined);if(h&&h['bPublished']===![])return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20Machine\x20\x22'+d+'\x22\x20is\x20NOT\x20published.\x20'+'Binding\x20an\x20unpublished\x20Machine\x20into\x20a\x20Service\x20aborts\x20on-chain\x20(the\x20binding\x20requires\x20a\x20'+'published\x20machine\x20—\x20machine\x20E_NOT_PUBLISHED=2).\x20'+'Fix:\x20publish\x20the\x20Machine\x20first\x20(onchain_operations\x20machine\x20with\x20publish:true),\x20then\x20bind\x20it.'};if(!h)return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20Machine\x20\x22'+d+'\x22\x20could\x20not\x20be\x20resolved\x20on-chain.\x20'+'Check\x20the\x20name/id\x20and\x20network\x20(env.network)\x20—\x20publishing\x20locks\x20the\x20reference.'};return{'ok':!![]};}const f=a?.['object']!=null&&typeof a['object']==='object';if(f)return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20a\x20NEW\x20Service\x20cannot\x20be\x20published\x20without\x20a\x20Machine.\x20'+'On-chain\x20publish\x20itself\x20does\x20not\x20check\x20this\x20(F-004),\x20but\x20the\x20result\x20is\x20a\x20dead\x20store:\x20'+'orders\x20cannot\x20progress\x20without\x20a\x20bound\x20machine,\x20and\x20the\x20machine\x20binding\x20is\x20frozen\x20after\x20'+'publish\x20(E_ALREADY_PUBLISHED=6)\x20—\x20the\x20Service\x20can\x20never\x20take\x20an\x20order\x20and\x20can\x20never\x20be\x20fixed.\x20'+'Fix:\x20create\x20+\x20publish\x20the\x20Machine\x20first,\x20then\x20bind\x20it\x20in\x20this\x20call\x20(machine:<name_or_id>).'};const g=typeof a?.['object']==='string'?a['object']:undefined;if(g){const i=await e(g)['catch'](()=>undefined);if(i&&(i['type']===undefined||i['type']==='Service')){const j=i['machine'];if(!j)return{'ok':![],'reason':'HARD\x20PRE-CHECK\x20FAILED:\x20Service\x20\x22'+g+'\x22\x20has\x20NO\x20Machine\x20bound\x20on-chain\x20and\x20none\x20is\x20'+'provided\x20in\x20this\x20patch.\x20The\x20machine\x20binding\x20is\x20frozen\x20after\x20publish\x20'+'(E_ALREADY_PUBLISHED=6)\x20—\x20if\x20it\x20publishes\x20now,\x20it\x20can\x20never\x20take\x20an\x20order\x20(F-004\x20dead\x20store).\x20'+'Fix:\x20create\x20+\x20publish\x20a\x20Machine,\x20then\x20bind\x20it\x20in\x20this\x20same\x20call\x20(machine:<name_or_id>).'};}}return{'ok':!![]};}export function isPassportVerifyFailure(a,b){if(/Identifier\("passport"\)/['test'](a)&&/MoveAbort\([\s\S]*,\s*7\s*\)/['test'](a))return!![];if(/::passport::/['test'](a)&&/abort code:\s*7\b/['test'](a))return!![];return b&&/abort code:\s*7\b/['test'](a);}function pickSubmissionCallForDiagnosis(a){for(const b of[a?.['submission'],a?.['info']]){if(b&&typeof b==='object'&&Array['isArray'](b['guard'])&&Array['isArray'](b['submission']))return b;}return undefined;}async function diagnoseGuardFailure(a,b){let c=pickSubmissionCallForDiagnosis(a),e=![];!c&&isBuyGuardAbortContext(a,b)&&(c=await synthesizeBuyGuardSubmissionForDiagnosis(a),e=c!==undefined);if(!isPassportVerifyFailure(b,c!==undefined))return undefined;if(!c)return undefined;const f=getEnvConfig(a?.['env']),g=await diagnose_passport_failure(f,c);if(g['failed_index']===null||g['failed_guard']===null)return'Guard\x20diagnosis\x20(dry-run):\x20'+g['hint'];const h=e?'Guard\x20diagnosis\x20(dry-run):\x20this\x20buy\x20was\x20gated\x20by\x20the\x20service\x27s\x20on-chain\x20buy_guard;\x20'+('the\x20first\x20failing\x20impact\x20guard\x20is\x20#'+g['failed_index']+'\x20('+g['failed_guard']+').\x20'+g['hint']):'Guard\x20diagnosis\x20(dry-run):\x20the\x20first\x20failing\x20impact\x20guard\x20is\x20#'+g['failed_index']+'\x20'+('('+g['failed_guard']+').\x20'+g['hint']);try{const i=await submissionItemsForGuard(g['failed_guard'],c),j=await loadGuardJsonFromChain(g['failed_guard'],f?.['network']),k=[];if(j){const l=renderGuardLegMap(j['json']['root'],j['json']['table'],i);k['push'](...l);}if(j){const m=(i??[])['map'](p=>{const q=Number(p['identifier']);if(!Number['isInteger'](q)||q<0x0||q>0xff)return undefined;const r=j['json']['table']['find'](s=>s['identifier']===q);if(!r||r['value_type']===undefined)return undefined;return{'identifier':q,'value_type':r['value_type'],'value':p['value']};})['filter'](p=>p!==undefined),n=(c['guard']??[])['map'](p=>typeof p?.['object']==='string'&&p['object']['startsWith']('0x')?p['object']:undefined)['filter'](p=>typeof p==='string'),o=await verifyGuardFailureLegs(f,g['failed_guard'],m,n);if(o['verdict']==='pass')k['push']('On-chain\x20leg\x20evaluation\x20(production\x20evaluator):\x20this\x20guard\x20PASSES\x20with\x20the\x20supplied\x20submission\x20—\x20the\x20E_VERIFY_FAILED\x20came\x20from\x20a\x20different\x20guard\x20or\x20a\x20different\x20submission\x20state.');else o['root_logic']?k['push']('On-chain\x20leg\x20evaluation\x20(production\x20evaluator):\x20legs\x20['+o['false_legs']['join'](',\x20')+']\x20of\x20the\x20'+o['root_logic']['toUpperCase']()+'\x20root\x20are\x20FALSE.\x20'+o['hint']):k['push']('On-chain\x20leg\x20evaluation\x20(production\x20evaluator):\x20the\x20single\x20root\x20condition\x20is\x20FALSE.\x20'+o['hint']);}if(k['length']>0x0)return h+'\x0a'+k['join']('\x0a');}catch{}return h;}async function submissionItemsForGuard(a,b){for(const c of Array['isArray'](b['submission'])?b['submission']:[]){let d=typeof c?.['guard']==='string'?c['guard']:undefined;if(!d)continue;!d['startsWith']('0x')&&(d=await LocalMark['Instance']()['get_address'](d)['catch'](()=>undefined)??d);if(d===a&&Array['isArray'](c['submission']))return c['submission'];}return undefined;}export async function synthesizeBuyGuardSubmissionForDiagnosis(a){try{const b=a?.['data']?.['object'];if(typeof b!=='string'||b['trim']()==='')return undefined;const c=getEnvConfig(a?.['env']),d=await query_serviceContext({'service':b,'no_cache':!![],'network':c?.['network']}),e=d?.['buy_guard'];if(!e?.['object'])return undefined;const f=[{'object':e['object'],'impack':!![]}];for(const g of Array['isArray'](e['relies'])?e['relies']:[]){typeof g==='string'&&!f['some'](h=>h['object']===g)&&f['push']({'object':g,'impack':![]});}return{'guard':f,'submission':[]};}catch{return undefined;}}export function isBuyGuardAbortContext(a,b){return a?.['operation_type']==='service'&&a?.['data']?.['order_new']!=null&&/abort code:\s*7\b/['test'](b);}async function autoHoldAfterClaim(a,b,c){if(typeof c!=='string'||!c)return undefined;const d=await resolveHoldableEdges({'progressRef':c,'accountName':a?.['account']??'','network':a?.['network'],'noCache':!![]});if(!d||d['edges']['length']===0x0)return undefined;const f=[],g=[],h=[];for(const i of d['edges']){const j=i['forward']+'\x20->\x20'+i['next_node'];if(!i['holdable']){h['push'](j);continue;}try{const k=new CallOrder({'object':b,'progress':{'op':'hold','operation':{'next_node_name':i['next_node'],'forward':i['forward']},'message':'arbitration\x20claimed\x20-\x20settlement\x20held\x20(E-17a)'}}),l=await k['call'](a);if(l&&typeof l==='object'&&!('error'in l))f['push'](j);else g['push'](j);}catch{g['push'](j);}}return{'held':f,'failed':g,'notHoldable':h};}export async function handleOnchainOperations(b){let c,h=[];async function k(l,m,p,u,x){const y=new Set(['service','machine','progress','repository','arbitration','contact','treasury','reward','allocation','permission','guard','personal','demand','order','proof']);if(!y['has'](p))return;if(!u||typeof u!=='object'||'error'in u)return;if(!u['digest'])return;if(x!==undefined)try{const z=collectOnChainNamedObjectRequests(x);if(z['length']>0x0){const A=await registerLocalMarksForCreatedObjects(z,ResponseData(u),p,{'getAddress':B=>LocalMark['Instance']()['get_address'](B,m),'put':B=>LocalMark['Instance']()['put'](B,m)});A['failed']['length']>0x0&&console['warn']('[nameRegistration]\x20'+A['failed']['length']+'\x20name(s)\x20could\x20not\x20be\x20registered\x20locally:\x20'+A['failed']['map'](B=>B['name']+'\x20('+B['error']+')')['join'](',\x20'));}}catch{}try{const B=operationPrimaryType(p),C=B?ResponseData(u)['find'](D=>D['change']==='created'&&D['object']&&String(D['type'])===String(B)):undefined;if(B&&C?.['object']){const D=C['object'],[E,F]=await Promise['all']([LocalMark['Instance']()['list']({'address':D}),LocalMark['Instance']()['get_address'](autoLocalMarkName(String(B),D),m)['catch'](()=>undefined)]),G=planAutoLocalMark({'operationType':p,'created':ResponseData(u),'existingNamesForAddress':E??[],'existingAddressForName':F});G&&(await LocalMark['Instance']()['put']([{'name':G['name'],'address':G['address'],'tags':G['tags']}],m),console['warn']('[autoMark]\x20created\x20'+p+'\x20registered\x20locally\x20as\x20'+G['note']));}}catch{}if(!l)return;try{const H=ResponseData(u),I=H['filter'](J=>J['change']==='created'&&J['object']);if(l&&I['length']>0x0){const J=I['filter'](K=>typeof K['type_raw']==='string'&&K['type_raw']['includes']('::'))['map'](K=>({'type':K['type_raw']['split']('::')['pop'](),'object':K['object']}));if(J['length']>0x0){const K=await goalEngine['registerActObjects'](l,J,m??'default');K>0x0&&console['warn']('[autoRegisterResults]\x20'+K+'\x20created\x20object(s)\x20registered\x20to\x20goal\x20'+l+'\x20(ACT\x20station)');}}}catch{}}try{if(typeof b==='object'&&b!==null&&'description'in b&&!('operation_type'in b)){const E=b['description'],F=typeof E==='string'&&(E['includes']('operation_type')||E['includes']('data'));if(F)throw new Error('Invalid\x20parameter\x20structure.\x20Parameters\x20should\x20NOT\x20be\x20wrapped\x20in\x20\x27description\x27\x20field.\x0a'+'Correct\x20format:\x20{\x20operation_type:\x20\x27...\x27,\x20data:\x20{...}\x20}\x0a'+'Incorrect\x20format:\x20{\x20description:\x20\x27{\x20operation_type:\x20...\x20}\x27\x20}');}c=strictParse(OnchainOperationsSchema,b,'onchain_operations\x20input');const l=getEnvConfig(c['env']);await expandBareReceiveIds(c,l?.['network']);const m=extractObjectOnlyRef(c);if(m!==undefined)return await queryObjectOnlyResult(c['operation_type'],m,l);try{const G=c['data']?.['object'];if(G&&typeof G==='object'&&G['replaceExistName']===!![]&&typeof G['name']==='string'&&G['name']['trim']()['length']>0x0){const H=await LocalMark['Instance']()['get'](G['name']['trim']());H?.['address']&&h['push']('NAME\x20REBIND:\x20local\x20name\x20\x27'+G['name']+'\x27\x20is\x20currently\x20bound\x20to\x20'+H['address']+'.\x20'+'replaceExistName=true\x20will\x20unbind\x20it\x20and\x20rebind\x20the\x20name\x20to\x20the\x20object\x20created/updated\x20by\x20this\x20'+('call\x20—\x20references\x20resolving\x20\x27'+G['name']+'\x27\x20will\x20point\x20to\x20the\x20NEW\x20object.\x20')+'If\x20this\x20is\x20unintentional,\x20drop\x20replaceExistName\x20or\x20choose\x20another\x20name.');}}catch{}if(!l['referrer']){const I=readStoredReferrer();if(I)l['referrer']=I;}if(l['network']==null)try{const J=await Config['Instance']()['network_get']();h['push']('env.network\x20not\x20set\x20—\x20routing\x20via\x20session\x20default\x20\x27'+String(J)+'\x27.\x20Pass\x20env.network\x20'+'explicitly\x20on\x20every\x20call\x20for\x20deterministic\x20routing\x20(the\x20response\x20network_source\x20echo\x20confirms\x20'+'which\x20network\x20served\x20the\x20call).');}catch{}if(l['dry_run']===!![]&&l['network']!=null)try{const K=await Config['Instance']()['network_get']();K&&K!==l['network']&&h['push']('NETWORK\x20DRIFT\x20(dry\x20run):\x20this\x20simulation\x20targets\x20\x27'+l['network']+'\x27\x20while\x20the\x20session\x20'+('default\x20is\x20\x27'+K+'\x27.\x20The\x20simulation\x20executed\x20(dry\x20runs\x20mutate\x20nothing),\x20but\x20the\x20')+('real\x20execution\x20WILL\x20land\x20on\x20\x27'+l['network']+'\x27\x20—\x20confirm\x20that\x20is\x20intended\x20before\x20dropping\x20dry_run.'));}catch{}const n=l['client_schema_version'],p=l['schema_strict_mode'],u=n?checkClientSchemaCompatibility(n,{'mode':p?'strict':'warn'}):undefined,x=(L,M,N)=>({'operation_type':c['operation_type'],'data':L,'expected':declareDispatchExpectation(c['operation_type'],L),'operation_id':stableOperationId(c['operation_type'],L),'pre_warnings':h['length']?h:undefined,'schema_check':u,'response_level':A,...M?{'evaluation':M}:{},...N?{'passport_test':N}:{}}),y=l['plan_approval'],z=l['network'],A=l['response_level'];if(l['confirmed']!==!![]&&l['dry_run']!==!![]){const L=await maybeGuardSubmissionConfirmation(c,l);if(L)return L;}delete l['confirmed'],delete l['user_intent_phrases'],delete l['client_schema_version'],delete l['response_level'],delete l['schema_strict_mode'],await resolveNamedObjectsInPlace(c['data']);const B=getSkillsHintForOnchain(c['operation_type'],c['data']);B&&h['push'](B);const C=getProjectSkillsHint();C&&h['push'](C);await assertReferencesResolve(c,l);{const M=markerOpFor(c['operation_type'],c['data']),N=c['data']!==undefined?c['data']:c,O=pendingInFlightResend(M,N,c['submission'],c['env']);if(O)return{'content':[{'type':'text','text':O}],'structuredContent':{'result':{'type':'error','error':O,'error_code':'state_conflict','retryable':!![],'recovery_hint':O}}};}switch(c['operation_type']){case'service':{const P=c['data'],Q=await detectServiceGuardCircularDependency(P);if(Q)return Q;const R=await checkSalesWipNetworkDeployment(P,l,h);if(R)return R;const S=checkSalesZeroPrice(P);if(S)return S;const T=describeBenchmarkIssueRisk(P?.['discount']?.['benchmark']);T&&h['push'](T);if(typeof P?.['discount']?.['time_ms_start']==='number'&&P['discount']['time_ms_start']>Date['now']()){const aj=Math['round']((P['discount']['time_ms_start']-Date['now']())/0xea60);h['push']('COUPON\x20NOT\x20YET\x20LIVE:\x20this\x20discount\x27s\x20window\x20opens\x20at\x20'+new Date(P['discount']['time_ms_start'])['toISOString']()+'\x20'+('(in\x20~'+aj+'\x20min).\x20Until\x20then\x20every\x20spend\x20attempt\x20aborts\x20with\x20E_DISCOUNT_TIME_INVALID\x20')+'(buy\x20dry_run\x20code\x2035)\x20even\x20though\x20the\x20coupon\x20is\x20already\x20minted\x20and\x20listed\x20as\x20usable\x20—\x20'+'do\x20NOT\x20distribute\x20it\x20to\x20recipients\x20before\x20the\x20window\x20opens.');}const U=await checkDiscountFloorBeforeIssue(P,l?.['network'],{'resolveAddress':async ak=>LocalMark['Instance']()['get_address'](ak)['catch'](()=>undefined)??undefined,'fetchObjects':async(ak,al)=>{const am=await query_objects({'objects':ak,'network':al});return am?.['objects']??[];}});if(U['block'])return{'content':[{'type':'text','text':U['block']}],'structuredContent':{'result':{'type':'error','error':U['block'],'error_code':'discount_zero_floor','retryable':![],'recovery_hint':'Lower\x20discount_value\x20so\x20the\x20cheapest\x20SKU\x20still\x20pays\x20>=\x201\x20smallest\x20unit,\x20'+'switch\x20the\x20coupon\x20to\x20RATES\x20(type\x200)\x20with\x20a\x20value\x20below\x2010000,\x20or\x20price\x20a\x20'+'deliberate\x20free\x20tier\x20at\x201\x20smallest\x20unit\x20/\x20deliver\x20it\x20outside\x20the\x20sales\x20rails\x20'+'(allow_zero_total\x20waives\x20nothing\x20—\x20BSX-F07).'},'message':U['block']}};U['warning']&&h['push'](U['warning']);const V=await prepareFundOperation(P,'service',l?.['network']);if(V['blockingErrors']['length']>0x0)return buildFundBlockResult(V,'service');h['push'](...V['warnings']);if(V['confirmation']){h['push'](V['confirmation']['message']);const ak=a523b(V['confirmation']);if(ak)h['push'](ak);}const W=await warnMerchantCompensationFundLow(P,l?.['network'],h);if(W)return W;const X=P?.['order_allocators'];if(X&&typeof X==='object'){const al=Array['isArray'](X['allocators'])?X['allocators']:[];for(let am=0x0;am<al['length'];am++){const an=al[am],ao=Array['isArray'](an?.['sharing'])?an['sharing']:[];if(ao['length']<=0x1)continue;const ap=new Map();for(let aq=0x0;aq<ao['length'];aq++){const ar=ao[aq]?.['who'];let as=typeof ar==='string'?ar:'';if(!as){const au=classifyRecipient(ar);if(au?.['kind']==='entity')as='Entity:'+au['address'];else{if(au?.['kind']==='signer')as='Signer';else{if(au?.['kind']==='submission')as='Guard:'+au['identifier'];else{if(ar)as=JSON['stringify'](ar);}}}}if(!as)continue;const at=ap['get'](as)??0x0;ap['set'](as,at+0x1);}for(const [av,aw]of ap){aw>0x1&&h['push']('DUPLICATE\x20SHARING\x20ENTITY:\x20Allocator['+am+']\x20has\x20entity\x20\x22'+av+'\x22\x20appearing\x20'+aw+'\x20times\x20'+'in\x20the\x20sharing\x20array.\x20This\x20is\x20likely\x20a\x20configuration\x20error\x20—\x20each\x20entity\x20should\x20appear\x20'+('at\x20most\x20once\x20per\x20allocator.\x20Total\x20sharing:\x20'+aw*0x64+'%\x20to\x20the\x20same\x20entity.\x20')+'If\x20intentional,\x20ignore\x20this\x20warning.');}}}if(X){const ax=checkOrderAllocatorsPrePublish(X,h);if(ax)return ax;const ay=await checkEntityRecipientGate(X,'service.order_allocators',h);if(ay)return ay;warnAmountEscrowDeadlock(X,P?.['sales'],h);}const Y=c['data']?.['order_new']?.['buy']?.['items'];if(Array['isArray'](Y))for(const az of Y){az&&typeof az==='object'&&'quantity'in az&&!('stock'in az)&&(az['stock']=az['quantity'],delete az['quantity']);}const Z=c['data']?.['order_new']?.['order_required_info'],a0=typeof Z==='string'?priorProofConsumptions(Z):[];a0['length']>0x0&&h['push']('PROOF\x20REUSE\x20(informational):\x20the\x20WTS\x20Proof\x20\x27'+Z+'\x27\x20already\x20anchored\x20'+('order_required_info\x20'+a0['length']+'\x20time(s)\x20earlier\x20this\x20session')+(a0[0x0]?.['service']?'\x20(service:\x20'+a0[0x0]['service']+')':'')+'.\x20Reuse\x20is\x20acceptable\x20and\x20privacy-preserving\x20—\x20a\x20Proof\x20records\x20the\x20contact\x20channel,\x20'+'not\x20an\x20order;\x20do\x20NOT\x20mint\x20a\x20per-order\x20proof\x20(that\x20would\x20publicly\x20link\x20orders).\x20'+'Acceptance\x20of\x20the\x20delivered\x20info\x20is\x20the\x20merchant\x27s\x20confirming\x20forward\x20on\x20this\x20order.');const a1=await checkDiscountThresholdBeforeBuy(c['data']??P,l?.['network'],{'resolveAddress':async aA=>LocalMark['Instance']()['get_address'](aA)['catch'](()=>undefined)??undefined,'fetchObjects':async(aA,aB)=>{const aC=await query_objects({'objects':aA,'network':aB});return aC?.['objects']??[];}});if(a1)return{'content':[{'type':'text','text':a1}],'structuredContent':{'result':{'type':'error','error':a1,'error_code':'discount_benchmark_unmet','retryable':![],'recovery_hint':'The\x20coupon\x20would\x20be\x20consumed\x20with\x20no\x20discount\x20because\x20this\x20order\x27s\x20total\x20is\x20'+'below\x20the\x20coupon\x27s\x20threshold.\x20Raise\x20the\x20order\x20total\x20above\x20the\x20threshold,\x20omit\x20'+'\x27discount\x27\x20to\x20pay\x20the\x20list\x20price\x20and\x20keep\x20the\x20coupon,\x20or\x20use\x20a\x20coupon\x20issued\x20'+'without\x20a\x20threshold.'},'message':a1}};let a2=[];if(P?.['publish']===!![]){a2=await collectArbitrationRefsForPublish(P,l);const aA=await checkArbitrationsBeforePublish(a2,l,h);if(aA)return aA;if(X){const aB=await checkRefundRecipientSatisfiability(X,l,h);if(aB)return aB;}}warnPermissionAutoCreation(c['data'],'Service',h);let a3;if(c['data']?.['order_new']){const aC=await probeOrderNewWipReachability(c['data'],l?.['network']);if(aC)return aC;const aD=await deriveTotalPayIfOmitted(c['data'],l?.['network']);if(aD)h['push'](aD);const aE=gateOrderNewZeroTotal(c['data']);if(aE)return aE;const aF=await warnOrderNewFundCoverage(c['data'],l?.['network']);aF&&h['push'](aF);const aG=await gateOrderNewAmountLegCoverage(c['data'],l?.['network']);if(aG)return aG;a3=beginInFlight('order_new',c['data'],l);}const a4=await prepareSaleItemOp(P,l?.['network']);if(a4&&'block'in a4)return a4['block'];const a5=await prepareRestockOrderOp(P,l?.['network']);if(a5)return a5;P?.['restock']&&h['push']('RESTOCK\x20/\x20REFUND-WINDOW\x20DISCLOSURE:\x20restock\x20puts\x20a\x20refunded\x20order\x27s\x20purchased\x20units\x20back\x20on\x20'+'shelf\x20and\x20reopens\x20that\x20stock\x20for\x20sale\x20(the\x20order\x20path\x20is\x20two-pass\x20all-or-nothing\x20and\x20'+'once-per-order).\x20If\x20this\x20Service\x27s\x20machine\x20(or\x20its\x20template)\x20has\x20NO\x20refund-terminal\x20gate\x20—\x20'+'an\x20edge/guard\x20that\x20still\x20lets\x20orders\x20reach\x20a\x20refund\x20terminal\x20state\x20—\x20orders\x20inside\x20their\x20'+'refund\x20window\x20may\x20lose\x20refund\x20eligibility\x20or\x20create\x20fund-accounting\x20ambiguity\x20once\x20the\x20'+'restocked\x20units\x20are\x20resold.\x20Before\x20relisting,\x20confirm\x20the\x20machine\x27s\x20refund\x20rail\x20remains\x20'+'reachable\x20after\x20this\x20restock.');const a6=await prepareSalesAddDuplicateGate(P,l?.['network'],l);if(a6)return a6;const a7=await gateServiceBuyGuardMount(c['data'],l?.['network']);if(a7)return a7;const {reentry_kind:a8,...a9}=c['data'],aa=new CallService(a9);let ab;try{ab=c['submission']?await aa['call_with_submission'](l,await transformSubmission(c['submission'])):await aa['call'](l);}catch(aH){const aI=aH['message']??String(aH);if(P?.['order_allocators_append']!=null&&(/allocation/i['test'](aI)&&(/MoveAbort\(.*,\s*20\s*\)/['test'](aI)||/abort code:\s*20\b/['test'](aI))||/EALLOCATORS_NOT_EXTENSION/i['test'](aI))){const aJ=await describeAllocatorsNotExtensionDiff(P?.['object'],P['order_allocators_append'],l?.['network']);if(aJ)throw new Error(aJ+'\x0aOriginal\x20error:\x20'+aI);}if((P?.['order_new']?.['buy']?.['items']?.['length']??0x0)>0x0&&/coin not enough|E_COIN_NOT_ENOUGH|abort.*\b20\b/i['test'](aI))throw new Error('PURCHASE\x20ABORTED\x20(E_COIN_NOT_ENOUGH\x20/\x20abort\x2020):\x20the\x20payment\x20'+'total_pay\x20is\x20LESS\x20THAN\x20the\x20order\x20total.\x20On-chain\x20order\x20total\x20=\x20'+'sale.price\x20x\x20per-item\x20QUANTITY.\x20Common\x20cause:\x20the\x20inventory\x20number\x20'+'was\x20passed\x20as\x20the\x20purchase\x20quantity\x20(the\x20buy\x20item\x20field\x20is\x20the\x20'+'number\x20of\x20units\x20to\x20buy,\x20NOT\x20the\x20product\x27s\x20available\x20stock).\x20'+'Check\x20each\x20item\x27s\x20quantity\x20and\x20ensure\x20total_pay\x20>=\x20sum(price\x20x\x20quantity).\x20'+('Original\x20error:\x20'+aI));if(/not found|GetObjectExisted|resolve|LocalMark|failed to resolve/i['test'](aI)){const aK=typeof P?.['object']==='object'&&P?.['object']!==null?P['object']['permission']:undefined;throw new Error('DEPENDENCY\x20RESOLUTION\x20FAILED:\x20One\x20or\x20more\x20referenced\x20objects\x20could\x20not\x20be\x20resolved.\x0a'+('Original\x20error:\x20'+aI+'\x0a')+'Common\x20causes:\x0a'+'\x20\x201.\x20Object\x20name\x20typo\x20—\x20check\x20spelling\x20in\x20LocalMark\x0a'+'\x20\x202.\x20Object\x20not\x20yet\x20created\x20—\x20create\x20dependencies\x20first\x0a'+'\x20\x203.\x20Object\x20on\x20different\x20network\x20—\x20check\x20env.network\x0a'+('Referenced\x20objects\x20in\x20this\x20call:\x20machine='+(P?.['machine']??'<none>')+',\x20')+('buy_guard='+(P?.['buy_guard']??'<none>')+',\x20')+('permission='+(aK??'<inline/new>')+',\x20')+('arbitrations='+describeArbitrationPayload(P?.['arbitrations'])));}throw aH;}if(a3)recordInFlightOutcome(a3,ab);a4&&'prep'in a4&&ab?.['digest']&&await emitSaleItemOpReadback(a4['prep'],P,l?.['network'],h);if(P?.['discount']!=null&&ab?.['digest'])try{const aL=ResponseData(ab)['filter'](aM=>aM?.['change']==='created'&&typeof aM?.['type_raw']==='string'&&aM['type_raw']['includes']('::service::Discount')&&typeof aM?.['object']==='string');if(aL['length']>0x0){const aM=P['discount'],aN=aM?.['time_ms_end']!=null?new Date(Number(aM['time_ms_end']))['toISOString']():'n/a';if(aL['length']===0x1&&typeof aM?.['name']==='string'&&aM['name']['length']>0x0){const aO=aL[0x0]['object'],aP=await LocalMark['Instance']()['get_address'](aM['name'],l['network']);!aP||aP['toLowerCase']()===aO['toLowerCase']()?(await LocalMark['Instance']()['put']([{'name':{'value':aM['name']},'address':aO}],l['network']),h['push']('DISCOUNT\x20ISSUED:\x20coupon\x20\x22'+aM['name']+'\x22\x20is\x20live\x20at\x20'+aO+'\x20(bound\x20to\x20this\x20service,\x20expires\x20'+aN+',\x20single-use\x20—\x20burned\x20at\x20buy).\x20Reference\x20it\x20as\x20order_new.buy.discount:\x20\x22'+aM['name']+'\x22\x20or\x20by\x20the\x20object\x20ID.')):h['push']('DISCOUNT\x20ISSUED:\x20coupon\x20\x22'+aM['name']+'\x22\x20is\x20live\x20at\x20'+aO+'\x20(expires\x20'+aN+',\x20single-use).\x20LocalMark\x20name\x20\x22'+aM['name']+'\x22\x20already\x20points\x20elsewhere\x20('+aP+')\x20—\x20reference\x20the\x20coupon\x20by\x20its\x20object\x20ID\x20in\x20order_new.buy.discount.');}else h['push']('DISCOUNT\x20ISSUED:\x20'+aL['length']+'\x20coupon(s)\x20live\x20(expires\x20'+aN+',\x20single-use\x20—\x20burned\x20at\x20buy):\x20'+(''+aL['slice'](0x0,0x5)['map'](aQ=>aQ['object'])['join'](',\x20')+(aL['length']>0x5?',\x20...':'')+'.\x20')+'Each\x20recipient\x20holds\x20their\x20own\x20copy;\x20reference\x20one\x20by\x20its\x20object\x20ID\x20in\x20order_new.buy.discount.');}}catch(aQ){h['push']('DISCOUNT\x20ISSUED:\x20the\x20transaction\x20succeeded\x20but\x20coupon\x20disclosure\x20failed:\x20'+(aQ?.['message']??String(aQ)));}P?.['order_new']&&typeof Z==='string'&&recordProofConsumption(Z,typeof P?.['object']==='string'?P['object']:undefined);const ac=P?.['object']!=null&&typeof P['object']==='object',ad=P?.['compensation_fund_add']!=null;ac&&!ad&&h['push']('Service.compensation_fund\x20balance\x20is\x200\x20—\x20no\x20refund\x20protection\x20for\x20buyers.\x20'+'If\x20buyers\x20need\x20refund\x20protection,\x20call\x20service.compensation_fund_add\x20with\x20a\x20Coin<T>\x20'+'to\x20deposit.\x20Without\x20deposit,\x20arbitration\x20rulings\x20cannot\x20withdraw\x20compensation\x20'+'from\x20this\x20Service.\x20(Note:\x20some\x20industries\x20like\x20freelance\x20do\x20not\x20require\x20this;\x20'+'the\x20evaluation\x20engine\x20will\x20check\x20industry-specific\x20requirements.)');if(ac&&ad&&P?.['compensation_fund_add']?.['balance']!=null){const aR=P['compensation_fund_add']['balance'],aS=Array['isArray'](P?.['sales'])?P['sales']:Array['isArray'](P?.['sales']?.['sales'])?P['sales']['sales']:[],aT=b6=>{if(typeof b6==='number'&&Number['isFinite'](b6))return b6;if(typeof b6==='string'&&/^\d+$/['test'](b6['trim']()))return Number(b6['trim']());return undefined;},aU=b6=>typeof b6==='string'&&/^\d*\.?\d+\s*[A-Za-z]{2,10}$/['test'](b6['trim']())?Number['parseFloat'](b6['trim']()):undefined,aV=aS['map'](b6=>b6?.['price'])['filter'](b6=>b6!=null),aW=aT(aR),aX=aU(aR),aY=aV['map'](aT),aZ=aV['map'](aU),b0=aV['length']>0x0&&aY['every'](b6=>b6!==undefined)&&aW!==undefined,b1=aV['length']>0x0&&aZ['every'](b6=>b6!==undefined)&&aX!==undefined,b2=b0?aW:b1?aX:undefined,b3=b0?aY:b1?aZ:[],b4=b3['length']>0x0?Math['max'](...b3):undefined,b5=0x3;b2!==undefined&&b4!==undefined&&b4>0x0&&b2<b5*b4&&h['push']('COMPENSATION\x20COVERAGE\x20BELOW\x20CEILING:\x20compensation_fund\x20deposit\x20('+b2+')\x20is\x20less\x20than\x20'+(b5+'x\x20the\x20highest\x20SKU\x20price\x20=\x20'+b5*b4+'\x20')+('(highest\x20SKU\x20price\x20itself:\x20'+b4+').\x20The\x20chain\x20caps\x20any\x20award\x20at\x20')+(b5+'x\x20the\x20order\x20amount\x20(arb.move\x20MAX_INDEMNITY_MULTIPLE,\x20enforced\x20at\x20')+'ruling\x20time),\x20so\x20a\x20ruling\x20at\x20the\x20ceiling\x20would\x20abort\x20the\x20buyer\x27s\x20payout\x20with\x20code\x2027\x20'+'(E_COMPENSATION_NOT_MATCH)\x20even\x20though\x20the\x20ruling\x20is\x20valid.\x20'+('Recommend\x20depositing\x20>=\x20'+b5+'x\x20the\x20highest\x20price\x20via\x20compensation_fund_add.\x20')+'Above\x203x\x20is\x20optional\x20(it\x20only\x20buys\x20headroom\x20for\x20several\x20CONCURRENT\x20claims\x20against\x20the\x20same\x20'+'per-Service\x20pool,\x20which\x20is\x20empty\x20of\x20any\x20on-chain\x20concurrency\x20limit).');}const ae=P?.['publish']===!![];if(ae){const b6=gateServicePublishPreflight(P);if(b6)return b6;}if(ae){const b7=new Set(['audit_compensation_fund','audit_arbitrations']),b8=auditService(P,{'network':l?.['network']})['filter'](b9=>!b7['has'](b9['rule_id']));for(const b9 of b8){const ba=b9['severity']==='error'?'[AUDIT\x20ERROR]\x20':b9['severity']==='warning'?'[AUDIT]\x20':'[INFO]\x20';h['push'](ba+b9['message']+(b9['recommendation']?'\x20—\x20'+b9['recommendation']:''));}}let af=ae&&a2['length']>0x0;if(!ae&&!af&&ad){const bb=await collectArbitrationRefsForPublish(P,l);af=bb['length']>0x0;}if(ae&&!af&&ad)throw new Error('HARD\x20PRE-CHECK\x20FAILED:\x20Cannot\x20publish\x20Service\x20with\x20compensation_fund\x20>\x200\x20but\x20no\x20Arbitration\x20bound.\x0a'+'On-chain\x20rule:\x20assert!(arbitration_count\x20>\x200,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND).\x0a'+'The\x20transaction\x20WILL\x20ABORT\x20on-chain\x20if\x20you\x20proceed.\x0a'+'Fix:\x20(1)\x20Create\x20an\x20Arbitration\x20object\x20first\x20(onchain_operations\x20with\x20operation_type=\x27arbitration\x27).\x0a'+'\x20\x20\x20\x20\x20(2)\x20Bind\x20it\x20in\x20this\x20same\x20call:\x20data.arbitrations={op:\x27add\x27,\x20objects:[<arbitration_name_or_id>]}\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20\x20(array\x20shorthand\x20data.arbitrations=[...]\x20is\x20also\x20accepted),\x20or\x20bind\x20it\x20in\x20a\x20prior\x0a'+'\x20\x20\x20\x20\x20\x20\x20\x20\x20call\x20—\x20arbitrations\x20already\x20bound\x20on\x20an\x20existing\x20Service\x20are\x20detected\x20automatically.\x0a'+'\x20\x20\x20\x20\x20(3)\x20Then\x20call\x20publish=true.\x0a'+'Note:\x20After\x20publish,\x20arbitrations\x20can\x20still\x20be\x20ADDED\x20(but\x20not\x20removed\x20without\x20pause+lock).');ae&&!af&&!ad&&h['push']('WARNING:\x20Publishing\x20Service\x20without\x20arbitrations.\x20If\x20compensation_fund\x20was\x20'+'deposited\x20in\x20a\x20prior\x20call,\x20the\x20contract\x20WILL\x20ABORT\x20with\x20'+'E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND.\x20If\x20compensation_fund\x20is\x200,\x20'+'publish\x20will\x20succeed\x20but\x20buyers\x20have\x20no\x20dispute\x20resolution\x20path.\x20'+'Recommended:\x20bind\x20arbitrations\x20before\x20publish.');!ae&&ad&&!af&&h['push']('WARNING:\x20Depositing\x20compensation_fund\x20on\x20a\x20Service\x20without\x20arbitrations\x20bound.\x20'+'If\x20this\x20Service\x20is\x20already\x20published,\x20arbitration\x20rulings\x20will\x20not\x20be\x20able\x20to\x20'+'withdraw\x20compensation\x20from\x20this\x20Service.\x20Recommended:\x20bind\x20arbitrations\x20first,\x20'+'then\x20deposit\x20compensation_fund.');const ag=await buildGuardSubmissionPrompt(ab,'service',{'network':l?.['network'],'signer':l?.['account'],'service_address':typeof P?.['object']==='string'?P['object']:undefined});if(ag)h['push'](ag);let ah;if(P?.['order_new']&&typeof P?.['object']==='string'&&a523c('customer_intelligence'))try{ah=await evaluateServiceFromGraph(P['object'],{'context_network':l?.['network']});}catch{}const ai=handleCallResult(ab,x(P,ah));return k(y,z,c['operation_type'],ab,c['data'])['catch'](()=>{}),ai;}case'machine':{if(c['data']['node']&&typeof c['data']['node']==='object'&&'json_or_markdown_file'in c['data']['node']){const bo=c['data']['node']['json_or_markdown_file'];let bp;try{const br=resolve(bo);bp=readFileSync(br,'utf-8');}catch(bs){throw new Error('Failed\x20to\x20read\x20file\x20\x27'+bo+'\x27:\x20'+bs['message']);}const bq=parseMachineNodesFromText(bp);if(!bq['success']){const bt=a523a(bq['errors']);throw new Error('Machine\x20node\x20validation\x20failed\x20for\x20file\x20\x27'+bo+'\x27:\x0a\x0a'+bt);}if(!bq['data'])throw new Error('No\x20nodes\x20found\x20in\x20file\x20\x27'+bo+'\x27');h['push']('json_or_markdown_file\x20mode:\x20file\x20\x27'+bo+'\x27\x20parsed\x20to\x20'+bq['data']['length']+'\x20node(s)\x20and\x20'+'mapped\x20to\x20op:\x27add\x27\x20+\x20bReplace:true\x20(complete\x20in-place\x20replacement).\x20op:\x27set\x27\x20is\x20not\x20used\x20because\x20'+'it\x20is\x20rejected\x20on\x20an\x20existing\x20Machine;\x20on\x20a\x20fresh\x20Machine\x20the\x20two\x20are\x20equivalent.'),c['data']['node']={'op':'add','nodes':bq['data'],'bReplace':!![]};if(c['data']?.['publish']===!![]){const bu=machinePublishGateViolation(bq['data']);if(bu)throw new Error('Machine\x20publish\x20pre-check\x20failed\x20for\x20file\x20\x27'+bo+'\x27:\x0a\x0a'+bu);}}const bc=c['data'],bd=await checkMachinePermissionBeforePublish(bc,l);bd&&h['push'](bd);const be=bc?.['node']?.['nodes']??bc?.['node'];try{const bv=typeof bc?.['object']==='object'&&bc?.['object']!==null?bc['object']?.['name']:bc?.['object'];recordMachineNodeNames(bv,be);}catch{}if(Array['isArray'](be)){const bw=/^(dispute|disputed|arbitration|arb_|arb\.|resolve_dispute|start_arbitration|open_dispute)/i;for(const bx of be){const by=typeof bx==='object'?bx?.['name']:'';typeof by==='string'&&bw['test'](by)&&h['push']('ARBITRATION\x20SEPARATION\x20WARNING:\x20Machine\x20node\x20\x22'+by+'\x22\x20appears\x20to\x20be\x20an\x20arbitration-related\x20node.\x0a'+'CORE\x20PRINCIPLE:\x20A\x20merchant\x20cannot\x20handle\x20disputes\x20fairly\x20—\x20they\x20would\x20be\x20\x27both\x20player\x20and\x20referee\x27.\x0a'+'The\x20WoWok\x20smart\x20contract\x20design\x20makes\x20Arbitration\x20a\x20completely\x20separate\x20object:\x0a'+'\x20\x20-\x20Arbitration\x20has\x20its\x20own\x20Permission,\x20voting_guard,\x20usage_guard,\x20and\x20balance\x0a'+'\x20\x20-\x20Arb\x20instances\x20have\x20a\x207-state\x20lifecycle\x20managed\x20by\x20Arbitration,\x20not\x20by\x20Machine\x0a'+'\x20\x20-\x20The\x20Order\x20object\x20is\x20the\x20bridge:\x20it\x20has\x20\x27progress\x27\x20(Machine)\x20and\x20\x27dispute\x27\x20(Arb\x20list)\x20fields\x0a'+'\x20\x20-\x20When\x20Arb\x20rules,\x20the\x20Order\x20executes\x20the\x20compensation\x20—\x20the\x20ONLY\x20connection\x20to\x20the\x20business\x20flow\x0a\x0a'+'CORRECT\x20PATTERN:\x0a'+'\x20\x20-\x20Machine:\x20business\x20states\x20only\x20(ordered\x20->\x20shipped\x20->\x20delivered\x20->\x20completed)\x0a'+'\x20\x20-\x20Arbitration:\x20separate\x20object\x20with\x20its\x20own\x20Permission\x20(NOT\x20shared\x20with\x20Service)\x0a'+'\x20\x20-\x20Arb:\x207-state\x20lifecycle\x20(Principal_confirming\x20->\x20Arbitrator_confirming\x20->\x20Voting\x20->\x20Arbitrated\x20->\x20Objectionable\x20->\x20Finished\x20->\x20Withdrawn)\x0a'+'\x20\x20-\x20R-M1-11:\x20NEVER\x20name\x20nodes\x20\x27refunded\x27/\x27disputed\x27/\x27arb\x27/\x27refund\x27\x20—\x20use\x20business\x20states\x20(\x27cancelled\x27/\x27returned\x27)\x20for\x20dispute\x20OUTCOMES;\x20refunds\x20route\x20via\x20Allocator\x20triggered\x20by\x20those\x20states,\x20disputes\x20via\x20the\x20separate\x20Arbitration\x20object\x0a\x0a'+'If\x20this\x20node\x20name\x20is\x20a\x20legitimate\x20business\x20state\x20(not\x20arbitration),\x20ignore\x20this\x20warning.');}}if(Array['isArray'](be)){const bz=be['map'](bA=>bA&&typeof bA==='object'&&bA['role']?bA['name']+'='+bA['role']:null)['filter'](Boolean);bz['length']>0x0&&h['push']('NODE\x20ROLES\x20(metadata):\x20'+bz['join'](',\x20')+'.\x20Roles\x20are\x20display-layer\x20semantics\x20'+'(draft/active/delivered/final/cancelled)\x20—\x20they\x20are\x20NOT\x20stored\x20on-chain\x20(nodes\x20carry\x20'+'name+pairs\x20only).\x20Consumers:\x20render\x20state\x20icons/colors\x20from\x20roles;\x20nodes\x20tagged\x20'+'\x27final\x27/\x27cancelled\x27\x20are\x20settlement\x20endpoints\x20—\x20advancing\x20to\x20them\x20should\x20trigger\x20the\x20'+'fund-release\x20reminder\x20(Allocation\x20trigger),\x20not\x20further\x20business\x20steps.');}try{let bA=Array['isArray'](be)?be:undefined,bB;if(!bA&&bc?.['publish']===!![]){const bC=await fetchChainAnchorContext(bc?.['object'],l);bC&&(bA=bC['nodes'],bB=bC['profiles']);}if(!be&&bc?.['publish']===!![]&&bA){const bD=machinePublishGateViolation(bA);bD&&h['push']('PUBLISH\x20GATE\x20(on-chain\x20publish\x20check):\x20'+bD);}if(bA){const bE=checkGuardAnchorReachability(bA,bB),bF=formatGuardAnchorWarnings(bE);if(bF)h['push'](bF);}}catch{}warnPermissionAutoCreation(c['data'],'Machine',h);const bf=c['data']?.['object'],bg=typeof bf==='string'?bf:typeof bf?.['name']==='string'?bf['name']:undefined,bh={};try{if(typeof bf==='string'&&bf['startsWith']('0x'))bh['resolvedAddress']=bf;else bg&&(bh['resolvedAddress']=await LocalMark['Instance']()['get_address'](bg)['catch'](()=>undefined)??undefined);bh['resolvedAddress']&&(bh['beforeCount']=(await fetchMachineNodes(bh['resolvedAddress'],l?.['network'],!![]))['length']);}catch{}const {reentry_kind:bi,...bj}=c['data'],bk=new CallMachine(bj),bl=c['submission']?await bk['call_with_submission'](l,await transformSubmission(c['submission'])):await bk['call'](l),bm=await buildGuardSubmissionPrompt(bl,'machine',{'network':l?.['network'],'signer':l?.['account'],'machine_address':c['data']?.['object']});if(bm)h['push'](bm);try{await emitMachineNodeReadback(bg,bh,c['data']?.['node']?.['op'],be,bl,l?.['network'],h);}catch{}const bn=handleCallResult(bl,x(c['data']));return k(y,z,c['operation_type'],bl,c['data'])['catch'](()=>{}),bn;}case'progress':{if(c['data']?.['operate']){h['push']('Progress\x20routing\x20fact:\x20on\x20an\x20order-bound\x20Progress\x20this\x20operate\x20call\x20'+'auto-routes\x20to\x20the\x20order-bound\x20path,\x20so\x20namedOperator=\x22\x22\x20(order\x20payer)\x20'+'forwards\x20execute\x20here\x20directly\x20—\x20switching\x20to\x20order.progress\x20is\x20NOT\x20required.\x20'+'If\x20this\x20Progress\x20is\x20standalone\x20(no\x20task\x20binding),\x20namedOperator=\x22\x22\x20forwards\x20'+'cannot\x20be\x20advanced\x20by\x20anyone\x20(no\x20order\x20payer\x20exists);\x20use\x20a\x20non-empty\x20'+'namedOperator\x20or\x20a\x20permissionIndex\x20forward\x20instead.');const bM=String(c['data']?.['operate']?.['operation']?.['forward']??'');/review/i['test'](bM)&&!c['data']?.['operate']?.['message']&&h['push']('Review-forward\x20hint:\x20the\x20real\x20exec\x20path\x20de-facto\x20requires\x20operate.message\x20for\x20Review-type\x20'+'forwards\x20(schema\x20marks\x20it\x20optional;\x20a\x20no-message\x20Review\x20failed\x20repeatedly\x20on\x20mainnet\x20until\x20the\x20'+'message\x20was\x20added).\x20Include\x20message:\x20\x27<review\x20text>\x27\x20in\x20this\x20call');const bN=bM+'\x20'+String(c['data']?.['operate']?.['operation']?.['next_node_name']??'');(/return.*(recv|receive|inspect)/i['test'](bN)||/^returned$/i['test'](String(c['data']?.['operate']?.['operation']?.['next_node_name']??'')))&&h['push']('NO-RESTOCK\x20reminder:\x20on-chain\x20stock\x20is\x20never\x20auto-restocked\x20—\x20a\x20return\x20only\x20moves\x20the\x20'+'Progress,\x20the\x20inventory\x20listing\x20is\x20not\x20refilled\x20automatically.\x20If\x20the\x20returned\x20goods\x20are\x20'+'resellable,\x20restock\x20the\x20sellable\x20item\x20via\x20the\x20sales\x20listing\x20before\x20relisting.');}const bG=typeof c['data']?.['review']?.['orderRef']==='string'?c['data']['review']['orderRef']:typeof c['data']?.['task']==='string'?c['data']['task']:undefined,bH=c['data']?.['review']&&c['submission']?await runReviewRepositoryWrite({'env':l,'submission':c['submission'],'review':c['data']['review'],'orderRef':bG}):[],bI=await snapshotProgressNodePreAdvance(c['data'],l),bJ=new CallProgress(c['data']),bK=c['submission']?await bJ['call_with_submission'](l,await transformSubmission(c['submission'])):await bJ['call'](l);if(!c['submission']&&bK&&typeof bK==='object'&&'submission'in bK){const bO=bK['submission'];if(Array['isArray'](bO)&&bO['length']>0x0){const bP=bO[0x0]?.['guard'];if(bP){const bQ={'operation':'progress_next','network':l?.['network'],'signer':l?.['account'],'progress_address':c['data']?.['object'],'order_address':c['data']?.['task']},bR=await generateGuardSubmissionPrompt(bP,bQ);bR&&h['push'](formatSubmissionPrompt(bR));}}}const bL=handleCallResult(bK,x(c['data']));bH['length']>0x0&&!(bK&&typeof bK==='object'&&'digest'in bK&&bK?.['effects']?.['status']?.['status']==='success')&&mergeReviewStepsIntoOutput(bL,bH,{'forwardOutcome':'failed\x20or\x20unconfirmed\x20—\x20the\x20pre-forward\x20review\x20write\x20MAY\x20have\x20landed\x20already\x20'+'(verify\x20via\x20the\x20repository\x20row\x20before\x20any\x20retry;\x20the\x20write\x20is\x20write-once)'});if(bK&&typeof bK==='object'&&'digest'in bK&&bK?.['effects']?.['status']?.['status']==='success'&&typeof c['data']?.['object']==='string'){const bS=c['data']?.['operate'],bT=bS?.['operation'],bU=await enrichWorkflowGuidance({'progressRef':c['data']['object'],'network':l?.['network'],'accountName':l?.['account'],'noCache':!![],'txResult':bK,'dryRun':l?.['dry_run']===!![],'compact':l?.['response_level']!=='full','operate':bT?.['forward']&&bT?.['next_node_name']?{'forward':bT['forward'],'next_node_name':bT['next_node_name'],'op':bS?.['op']}:undefined});mergeGuidanceIntoOutput(bL,bU,{'responseLevel':l?.['response_level']});}bK&&typeof bK==='object'&&'digest'in bK&&bK?.['effects']?.['status']?.['status']==='success'&&await annotateProgressAdvanceOutcome(bL,bI,bK,l);if(bK&&typeof bK==='object'&&'digest'in bK&&bK?.['effects']?.['status']?.['status']==='success'&&c['data']?.['review']){const bV={'env':l,'submission':c['submission'],'review':c['data']['review'],'orderRef':bG},bW=c['submission']?await runReviewRewardClaim(bV):await runReviewChain(bV),bX=[...bH,...bW];if(bX['length']>0x0)mergeReviewStepsIntoOutput(bL,bX);else{if(c['data']?.['review'])try{if(bL?.['structuredContent']&&typeof bL['structuredContent']==='object'){const bY=bL['structuredContent'];if(!bY['semantic']||typeof bY['semantic']!=='object')bY['semantic']={};bY['semantic']['warnings']=[...Array['isArray'](bY['semantic']['warnings'])?bY['semantic']['warnings']:[],'data.review\x20was\x20declared\x20but\x20produced\x20no\x20chained\x20steps\x20(missing\x20repository\x20and\x20reward_claim)\x20—\x20no\x20review\x20was\x20written\x20and\x20no\x20reward\x20was\x20claimed.'];}}catch{}}}return k(y,z,c['operation_type'],bK,c['data'])['catch'](()=>{}),bL;}case'repository':{const bZ=new CallRepository(c['data']),c0=c['submission']?await bZ['call_with_submission'](l,await transformSubmission(c['submission'])):await bZ['call'](l),c1=await buildGuardSubmissionPrompt(c0,'repository',{'network':l?.['network'],'signer':l?.['account'],'extra':{'repository':c['data']?.['object']}});if(c1)h['push'](c1);const c2=handleCallResult(c0,x(c['data']));return k(y,z,c['operation_type'],c0,c['data'])['catch'](()=>{}),c2;}case'arbitration':{const c3=await prepareFundOperation(c['data'],'arbitration',l?.['network']);if(c3['blockingErrors']['length']>0x0)return buildFundBlockResult(c3,'arbitration');h['push'](...c3['warnings']);if(c3['confirmation']){h['push'](c3['confirmation']['message']);const cc=a523b(c3['confirmation']);if(cc)h['push'](cc);}{const cd=c['data']['voting_deadline_change'],ce=cd?.['voting_deadline'];if(typeof ce==='number'&&ce<=Date['now']())return{'content':[{'type':'text','text':'voting_deadline_change\x20refused:\x20the\x20requested\x20deadline\x20is\x20not\x20in\x20the\x20future.\x20No\x20transaction\x20was\x20sent.'}],'structuredContent':{'result':{'type':'error','error':'voting_deadline\x20'+ce+'\x20is\x20<=\x20now\x20('+Date['now']()+').','error_code':'invalid_parameter','retryable':![],'recovery_hint':'Set\x20voting_deadline_change.voting_deadline\x20to\x20an\x20ms-epoch\x20timestamp\x20STRICTLY\x20in\x20the\x20future\x20and\x20resubmit.\x20Moving\x20the\x20deadline\x20into\x20the\x20past\x20is\x20refused\x20client-side:\x20it\x20would\x20silently\x20revoke\x20every\x20other\x20arbitrator\x27s\x20remaining\x20vote\x20window\x20(instant-sovereignty\x20loophole).'},'message':'voting_deadline_change\x20refused\x20—\x20the\x20new\x20deadline\x20must\x20be\x20strictly\x20in\x20the\x20future.'}};}const c4=new CallArbitration(c['data']),c5=c['submission']?await c4['call_with_submission'](l,await transformSubmission(c['submission'])):await c4['call'](l),c6=await buildGuardSubmissionPrompt(c5,'arbitration',{'network':l?.['network'],'signer':l?.['account'],'extra':{'arbitration':c['data']?.['object']}});if(c6)h['push'](c6);const c7=c['data']?.['object'],c8=c7!==null&&typeof c7==='object';c8&&c['data']?.['pause']!==![]&&(h['push']('ARBITRATION\x20ACTIVATION\x20REQUIRED:\x20a\x20newly\x20created\x20Arbitration\x20defaults\x20to\x20bPaused=true\x20—\x20'+'dispute\x20filing\x20aborts\x20with\x20E_PAUSED\x20until\x20unpaused.\x20Issue\x20'+'{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20pause:false}}\x20before\x20binding\x20it\x20'+'to\x20a\x20Service\x20or\x20accepting\x20disputes.\x20NOTE:\x20unpausing\x20requires\x20permission\x20356\x20—\x20'+'the\x20creator\x20passes\x20this\x20check\x20as\x20the\x20new\x20Permission\x27s\x20admin\x20(admins\x20are\x20exempt\x20'+'from\x20permission\x20checks);\x20any\x20OTHER\x20operator\x20needs\x20an\x20explicit\x20356\x20grant\x20first.'),h['push']('PERMISSION\x20INITIALIZATION\x20REQUIRED:\x20a\x20freshly\x20created\x20Arbitration\x20has\x20NO\x20permission\x20'+'grants\x20(350-368\x20all\x20unassigned)\x20—\x20every\x20NON-admin\x20caller\x20aborts\x20with\x20\x27Missing\x20permission\x27\x20'+'(code\x205);\x20the\x20new\x20Permission\x27s\x20admin\x20(its\x20creator)\x20always\x20passes\x20and\x20needs\x20no\x20grants.\x20'+'OPEN\x20VOTING\x20IS\x20NOT\x20PERMISSIONLESS:\x20an\x20empty\x20voting_guard\x20means\x20every\x20358\x20(vote)\x20grantee\x20'+'votes\x20with\x20EQUAL\x20weight\x20(1\x20person\x201\x20vote)\x20—\x20vote()\x20asserts\x20358\x20unconditionally:\x20only\x20the\x20'+'arb\x27s\x20Permission\x20admin\x20(its\x20creator,\x20by\x20default)\x20and\x20explicit\x20358\x20grantees\x20can\x20vote,\x20so\x20'+'grant\x20358\x20to\x20BOTH\x20disputing\x20parties\x20and\x20every\x20intended\x20non-admin\x20voter,\x20or\x20voting\x20collapses\x20'+'to\x20admin-only\x20(the\x20arb\x20admin\x20is\x20the\x20sole\x20voter\x20AND\x20judge).\x20'+'Recommended\x20grants\x20via\x20the\x20Arbitration\x27s\x20Permission\x20object\x20(permission_index_add)\x20for\x20'+'NON-admin\x20operators:\x20356\x20(pause/unpause),\x20357\x20(fee),\x20362\x20(voting\x20deadline),\x20363\x20(reset),\x20'+'364-366\x20(withdraw/fees\x20alloc/transfer),\x20367-368\x20(owner\x20receive/UM);\x20'+'arbitrator:\x20361\x20(confirm\x20materials,\x20starts\x20voting)\x20+\x20359\x20(issue\x20ruling).'));if(c8)try{const cf=c['data'],cg=Array['isArray'](cf?.['voting_guard']?.['guards'])?cf['voting_guard']['guards']:[],ch=[];for(const ck of cg){const cl=ck?.['vote_weight']?.['FixedValue'];if(typeof cl==='number'&&Number['isFinite'](cl)&&cl>=0x0)ch['push'](cl);}const ci=ch['reduce']((cm,cn)=>cm+cn,0x0),cj=checkArbitrationVenueOrder({'unpaused_at_creation':cf?.['pause']===![]?!![]:undefined,'voting_guard_count':cg['length'],'max_weight_share':cg['length']>0x0&&ch['length']===cg['length']&&ci>0x0?Math['max'](...ch)/ci:undefined,'fee':cf?.['fee'],'has_description':typeof cf?.['description']==='string'&&cf['description']['trim']()!==''?!![]:cf?.['description']===undefined?![]:undefined})['filter'](cm=>cm['order_id']!=='V1-activation');for(const cm of cj)h['push'](cm['message']);h['push'](venueOperatingDoctrine());}catch{}const c9=c['data'],ca=c7!==null&&typeof c7==='string'&&c9?.['pause']===![];if(ca){const cn=c4['content']?.['fee'],co=c9?.['fee']??cn,cp=co===0x0||co==='0'||co==='0.0'||co==='0WOW';co!=null&&cp&&h['push']('FREE\x20ARBITRATION:\x20this\x20Arbitration\x20activates\x20with\x20fee\x20=\x200\x20—\x20dispute\x20filers\x20pay\x20nothing\x20'+'(any\x20coin\x20they\x20send\x20is\x20refunded\x20on\x20filing;\x20only\x20self.fee\x20is\x20escrowed\x20for\x20the\x20arbitrator).\x20'+'The\x20arbitrator\x20earns\x20no\x20per-case\x20income\x20from\x20this\x20service.\x20If\x20this\x20is\x20intentional\x20'+'(e.g.\x20a\x20free-dispute\x20commercial\x20model),\x20ignore\x20this\x20warning;\x20to\x20charge\x20per\x20case,\x20set\x20'+'a\x20fee:\x20{operation_type:\x27arbitration\x27,\x20data:{object:\x27<arb>\x27,\x20fee:<amount>}}.');}if(typeof c9?.['vote']?.['arb']==='string'&&typeof l?.['account']==='string')try{const cq=c9['vote']['arb']['startsWith']('0x')?c9['vote']['arb']:await LocalMark['Instance']()['get_address'](c9['vote']['arb'])??undefined;if(cq){const cr=await query_objects({'objects':[cq],'no_cache':!![],'network':l?.['network']}),cs=cr?.['objects']?.[0x0],ct=cs?.['data']??cs,cu=Array['isArray'](ct?.['voting_guard'])?ct['voting_guard']['filter'](Boolean):[];if(cu['length']===0x0){const cv=typeof ct?.['permission']==='string'?ct['permission']:undefined;if(cv){const cw=await query_objects({'objects':[cv],'no_cache':!![],'network':l?.['network']}),cx=cw?.['objects']?.[0x0],cy=cx?.['data']??cx,cz=Array['isArray'](cy?.['admin'])?cy['admin']:[];if(!cz['includes'](l['account'])){const cA=await fetchEntityPermissions(cv,l?.['network']),cB=cA['get'](l['account'])??[];!cB['includes'](0x166)&&h['push']('VOTE\x20PRE-FLIGHT:\x20account\x20'+l['account']+'\x20holds\x20NO\x20permission\x20358\x20on\x20this\x20Arbitration\x27s\x20'+'Permission\x20('+cv+'),\x20and\x20the\x20arb\x20has\x20no\x20voting_guard\x20(plain-vote\x20mode\x20asserts\x20358\x20'+'unconditionally)\x20—\x20this\x20vote\x20will\x20be\x20REFUSED\x20before\x20any\x20transaction\x20is\x20sent.\x20Remedy:\x20the\x20arb\x27s\x20'+'Permission\x20admin\x20grants\x20358\x20(permission_index_add\x20on\x20'+cv+';\x20equal-weight\x201-person-1-vote),\x20'+'or\x20the\x20voter\x20uses\x20the\x20weighted\x20path\x20vote.voting_guard=<registered\x20guard>\x20(passport-authorized,\x20no\x20358).\x20'+'NOTE:\x20if\x20a\x20transport\x20\x27fetch\x20failed\x27\x20surfaces\x20during\x20the\x20permission\x20read,\x20the\x20vote\x20was\x20NOT\x20submitted\x20—\x20'+'nothing\x20is\x20sent\x20until\x20the\x20permission\x20check\x20passes;\x20do\x20not\x20run\x20commit-state\x20verification.');}}}}}catch{}c['data']?.['arbitration']&&(h['push']('RULING\x20DOES\x20NOT\x20SETTLE\x20ESCROW:\x20this\x20ruling\x20records\x20the\x20feedback\x20+\x20indemnity\x20on\x20the\x20Arb\x20case\x20'+'object\x20ONLY\x20—\x20it\x20moves\x20no\x20funds\x20and\x20does\x20NOT\x20adjust\x20the\x20order\x27s\x20escrow\x20(the\x20Machine\x20workflow\x20'+'and\x20its\x20Allocation\x20are\x20independent\x20of\x20arbitration;\x20there\x20is\x20no\x20on-chain\x20linkage).\x20To\x20actually\x20'+'pay\x20the\x20buyer,\x20the\x20dispute\x20must\x20be\x20confirmed\x20and\x20then\x20claimed\x20via\x20'+'{operation_type:\x27order\x27,\x20data:{object:\x27<order>\x27,\x20arb_claim_compensation:{...}}}\x20—\x20the\x20indemnity\x20'+'is\x20paid\x20from\x20the\x20Service\x27s\x20merchant-prepaid\x20compensation_fund\x20(NOT\x20from\x20escrow),\x20capped\x20at\x203x\x20the\x20'+'order\x20amount,\x20and\x20it\x20does\x20NOT\x20re-split\x20the\x20allocator\x20ratios\x20(partial\x20/\x20proportional\x20refunds\x20via\x20a\x20'+'verdict\x20are\x20not\x20expressible\x20on-chain).\x20Because\x20the\x20two\x20tracks\x20are\x20independent,\x20the\x20buyer\x20can\x20still\x20'+'be\x20paid\x20the\x20FULL\x20escrow\x20AND\x20the\x20indemnity:\x20to\x20prevent\x20the\x20dual\x20payout,\x20freeze\x20the\x20settlement\x20by\x20'+'holding\x20the\x20order\x27s\x20edge\x20to\x20\x27completed\x27\x20before\x20it\x20settles\x20(hold\x20permission\x20=\x20the\x20forward\x27s\x20execute\x20'+'permission;\x20a\x20merchant-only\x20edge\x20needs\x20the\x20merchant/keeper\x20to\x20hold\x20it),\x20or\x20explicitly\x20accept\x20both\x20payouts.'),h['push']('ESCROW\x20FORENSICS\x20(refund-then-claim):\x20the\x20reverse\x20ordering\x20—\x20escrow\x20refund\x20first,\x20indemnity\x20'+'claim\x20second\x20—\x20is\x20NOT\x20on-chain\x20blocked,\x20but\x20it\x20IS\x20on-chain\x20distinguishable.\x20The\x20order-side\x20fund\x20'+'facts\x20(amount,\x20escrow\x20balance,\x20withdraw\x20history,\x20claimed_by,\x20workflow\x20node)\x20are\x20attached\x20to\x20this\x20'+'result\x20as\x20order_fund_facts,\x20and\x20to\x20every\x20query\x20of\x20this\x20Arb\x20case\x20as\x20_order_fund_facts\x20—\x20read\x20them\x20'+'before\x20finalizing\x20the\x20indemnity.\x20If\x20the\x20escrow\x20was\x20already\x20released\x20to\x20the\x20buyer\x20before\x20filing\x20'+'(positive\x20escrow_deficit\x20/\x20payout\x20entries\x20in\x20withdraw_history),\x20net\x20the\x20award\x20against\x20'+'the\x20refunded\x20principal\x20—\x20compensate\x20the\x20delta,\x20not\x20the\x20full\x20loss;\x20the\x20defendant\x20can\x20attach\x20the\x20'+'same\x20forensics\x20to\x20the\x20case\x20statement.'));const cb=handleCallResult(c5,x(c['data']));try{const cC=!!c5&&typeof c5==='object'&&c5?.['effects']?.['status']?.['status']==='success';if(cC){const cD=c['data'],cE=cD?.['vote']?.['arb']??cD?.['confirm']?.['arb']??cD?.['arbitration']?.['arb']??cD?.['reset']?.['arb']??cD?.['feedback']?.['arb']??cD?.['arb_withdraw']?.['arb']??cD?.['voting_deadline_change']?.['arb'],cF=cD?.['dispute']?.['order'];if(cE||cF){const cG=await buildOrderFundFacts({'arbRef':cE,'orderRef':cF,'network':l?.['network']});cG&&(cb['structuredContent']['order_fund_facts']=cG['structured'],cb['content']['push']({'type':'text','text':cG['text']}));}}}catch{}try{const cH=c['data'],cI=!!c5&&typeof c5==='object'&&c5?.['effects']?.['status']?.['status']==='success',cJ=!!(cH?.['confirm']||cH?.['vote']||cH?.['arbitration']);cI&&cJ&&Array['isArray'](cb['content'])&&cb['content']['push']({'type':'text','text':'MONEY-MOVEMENT\x20CHECKLIST\x20—\x20this\x20adjudication\x20step\x20wrote\x20case\x20STATE\x20only\x20'+'(status\x20/\x20feedback\x20/\x20indemnity);\x20it\x20moved\x20NO\x20funds\x20and\x20paid\x20no\x20one:\x20no\x20wallet\x20balance\x20changed\x20'+'and\x20the\x20escrowed\x20case\x20fee\x20is\x20still\x20in\x20the\x20Arb\x20case.\x20To\x20actually\x20move\x20the\x20arbitration\x20fee,\x20'+'continue\x20in\x20order:\x20(1)\x20arb_withdraw\x20—\x20pulls\x20the\x20case\x20fee\x20into\x20the\x20Arbitration\x20(Registration)\x20'+'object\x27s\x20balance\x20pool\x20(immediately\x20from\x20state\x205\x20Finished;\x20from\x20state\x203\x20only\x20after\x20the\x2030-day\x20'+'no-objection\x20window;\x20refused\x20in\x20states\x200/1/2,\x20never\x20in\x20state\x204);\x20'+'(2)\x20fees_transfer\x20—\x20moves\x20the\x20Arbitration\x27s\x20ENTIRE\x20balance\x20pool\x20in\x20ONE\x20call\x20to\x20'+'to.allocation\x20(an\x20Allocation\x20object)\x20or\x20to.treasury\x20(a\x20Treasury\x20object),\x20single-key\x20\x27to\x27\x20'+'shape,\x20payment_index\x20required\x20(see\x20the\x20fees_transfer\x20field\x20description);\x20'+'(3)\x20treasury\x20target\x20only\x20—\x20treasury\x20receive:\x20\x22recently\x22\x20(permission\x20253)\x20intakes\x20the\x20'+'arrived\x20CoinWrapper,\x20then\x20treasury\x20withdraw\x20pays\x20out.\x20A\x20successful\x20arb_withdraw\x20with\x20no\x20'+'wallet\x20balance\x20change\x20is\x20EXPECTED\x20—\x20the\x20fee\x20sits\x20in\x20the\x20Arbitration\x20object\x27s\x20pool\x20until\x20'+'step\x20(2).\x20The\x20order-escrow\x20/\x20indemnity\x20track\x20is\x20independent\x20of\x20this\x20fee\x20track.'});}catch{}return k(y,z,c['operation_type'],c5,c['data'])['catch'](()=>{}),cb;}case'contact':{warnPermissionAutoCreation(c['data'],'Contact',h);const cK=new CallContact(c['data']),cL=c['submission']?await cK['call_with_submission'](l,await transformSubmission(c['submission'])):await cK['call'](l),cM=await buildGuardSubmissionPrompt(cL,'contact',{'network':l?.['network'],'signer':l?.['account']});if(cM)h['push'](cM);const cN=handleCallResult(cL,x(c['data']));return k(y,z,c['operation_type'],cL,c['data'])['catch'](()=>{}),cN;}case'treasury':{const cO=await prepareFundOperation(c['data'],'treasury',l?.['network']);if(cO['blockingErrors']['length']>0x0)return buildFundBlockResult(cO,'treasury');h['push'](...cO['warnings']);if(cO['confirmation']){h['push'](cO['confirmation']['message']);const cT=a523b(cO['confirmation']);if(cT)h['push'](cT);}const cP=new CallTreasury(c['data']),cQ=c['submission']?await cP['call_with_submission'](l,await transformSubmission(c['submission'])):await cP['call'](l),cR=await buildGuardSubmissionPrompt(cQ,'treasury',{'network':l?.['network'],'signer':l?.['account'],'extra':{'treasury':c['data']?.['object']}});if(cR)h['push'](cR);const cS=handleCallResult(cQ,x(c['data']));return k(y,z,c['operation_type'],cQ,c['data'])['catch'](()=>{}),cS;}case'reward':{const cU=await prepareFundOperation(c['data'],'reward',l?.['network']);if(cU['blockingErrors']['length']>0x0)return buildFundBlockResult(cU,'reward');h['push'](...cU['warnings']);if(cU['confirmation']){h['push'](cU['confirmation']['message']);const d0=a523b(cU['confirmation']);if(d0)h['push'](d0);}assertRewardRecipientSemantics(c['data']?.['guard_add']),await assertRewardReplayStamp(c['data']?.['guard_add'],l?.['network'],h),await checkRewardOnceArming(c['data'],l?.['network'],h);const cV=transformRewardInput(c['data']),cW=new CallReward(cV),cX=c['submission']?await cW['call_with_submission'](l,await transformSubmission(c['submission'])):await cW['call'](l);try{h['push'](...await verifyRewardEvidenceBindings(cX,c['data']?.['object'],c['data']?.['guard_add'],l?.['network']));}catch{}const cY=await buildGuardSubmissionPrompt(cX,'reward',{'network':l?.['network'],'signer':l?.['account'],'extra':{'reward':c['data']?.['object']}});if(cY)h['push'](cY);const cZ=handleCallResult(cX,x(c['data']));return k(y,z,c['operation_type'],cX,c['data'])['catch'](()=>{}),cZ;}case'allocation':{const d1=await prepareFundOperation(c['data'],'allocation',l?.['network']);if(d1['blockingErrors']['length']>0x0)return buildFundBlockResult(d1,'allocation');h['push'](...d1['warnings']);if(d1['confirmation']){h['push'](d1['confirmation']['message']);const d8=a523b(d1['confirmation']);if(d8)h['push'](d8);}if(c['data']?.['alloc_by_guard']&&c['submission']){const d9=new Set();for(const da of c['submission']['submission']||[]){for(const db of da?.['submission']||[]){const dc=typeof db?.['value']==='string'?db['value']:'';if(/^0x[0-9a-fA-F]{64}$/['test'](dc))d9['add'](dc);}}if(d9['size']>0x0)try{const dd=(await batchQueryObjectsByIds([...d9],l?.['network'],!![]))['filter'](dh=>dh?.['type']==='Order'),de=c['data']?.['acknowledge_dual_payout']===!![],df=await storeDualPayoutVerdict(l);let dg={'track':'unknown'};try{const dh=c['data'],di=dh?.['alloc_batch'],dj=Array['isArray'](di)&&di['length']>0x0?di:[dh?.['object']],dk=[];for(const dl of dj){if(typeof dl!=='string')continue;if(/^0x[0-9a-fA-F]{64}$/['test'](dl)){dk['push'](dl);continue;}const dm=await LocalMark['Instance']()['get_address'](dl)['catch'](()=>undefined)??undefined;if(typeof dm==='string'&&dm['startsWith']('0x'))dk['push'](dm);}if(dk['length']>0x0){let dn;const dp=dh?.['alloc_by_guard'];if(typeof dp==='string'&&/^0x[0-9a-fA-F]{64}$/['test'](dp))dn=dp;else typeof dp==='string'&&(dn=await LocalMark['Instance']()['get_address'](dp)['catch'](()=>undefined)??undefined);const dq=await batchQueryObjectsByIds(dk,l?.['network'],!![]),dr=du=>du['track']==='entity-directed'?0x0:du['track']==='unknown'?0x1:0x2;let ds;const dt=new Set();for(const du of dq??[]){if(!du)continue;const dv=classifyDualPayoutTrack(du?.['allocators'],dn);if(!ds||dr(dv)>dr(ds))ds=dv;if(dv['track']==='entity-directed'){for(const dw of dv['recipients']??[])dt['add'](dw);}}ds&&(dg=ds['track']==='entity-directed'?{'track':'entity-directed','recipients':Array['from'](dt)}:ds);}}catch{}for(const dx of dd){if(typeof dx['claimed_by']==='string'&&dx['claimed_by']['startsWith']('0x')){let dy;try{dy=(await batchQueryObjectsByIds([dx['claimed_by']],l?.['network'],!![]))?.['find'](dB=>dB?.['type']==='Arb');}catch{}const dz=dy?dy['indemnity']:undefined,dA=dy!=null&&(dz==null||String(dz['amount']??'0')==='0');if(dA){h['push']('DUAL\x20PAYOUT\x20N/A\x20(dismissal-sealed):\x20Order\x20'+dx['object']+'\x27s\x20arbitration\x20case\x20'+dx['claimed_by']+'\x20CONCLUDED\x20with\x20ZERO\x20compensation\x20'+'(indemnity\x20none/0\x20—\x20nothing\x20was\x20paid\x20from\x20the\x20compensation\x20fund).\x20claimed_by\x20only\x20SEALS\x20the\x20paired\x20rail\x20(order.move:119-143);\x20'+'this\x20escrow\x20release\x20is\x20the\x20sole\x20payout\x20for\x20the\x20order,\x20so\x20no\x20acknowledge_dual_payout\x20is\x20needed.\x20'+'Note:\x20on\x20rails\x20with\x20claimed_by\x20pairing\x20the\x20on-chain\x20guard\x20will\x20still\x20REJECT\x20the\x20sealed\x20refund\x20leg\x20(guard_rejected\x20=\x20the\x20pairing\x20working)\x20—\x20route\x20that\x20leg\x20via\x20the\x20paired\x20rail\x20instead.');continue;}if(!de){if(dg['track']==='entity-directed'){h['push']('DUAL\x20PAYOUT\x20ADVISORY\x20(entity-directed\x20release):\x20Order\x20'+dx['object']+'\x20carries\x20a\x20recorded\x20arbitration\x20indemnity\x20award\x20'+('(claimed_by='+dx['claimed_by']+';\x20compensation-fund\x20claim\x20state\x20per\x20the\x20Arb\x20case)\x20and\x20this\x20alloc_by_guard\x20releases\x20its\x20escrow\x20to\x20FIXED\x20')+('ENTITY\x20recipients\x20('+dg['recipients']['join'](',\x20')+')\x20—\x20no\x20buyer-receivable\x20leg,\x20so\x20the\x20buyer\x20')+'double-dip\x20block\x20does\x20not\x20apply.\x20Note\x20the\x20compensation\x20recipient\x20may\x20still\x20net\x20compensation\x20+\x20escrow\x20'+'(merchant\x20stacking);\x20verify\x20that\x20is\x20the\x20intended\x20commercial\x20outcome.');continue;}return{'content':[{'type':'text','text':'DUAL\x20PAYOUT\x20REFUSED\x20—\x20no\x20transaction\x20was\x20sent.\x20Order\x20'+dx['object']+'\x20carries\x20a\x20recorded\x20arbitration\x20indemnity\x20award\x20(claimed_by='+dx['claimed_by']+');\x20this\x20alloc_by_guard\x20would\x20ALSO\x20release\x20its\x20escrow'+(dg['track']==='order-directed'?'\x20to\x20order-directed\x20(guard-submitted)\x20recipients\x20—\x20on\x20refund\x20rails\x20that\x20is\x20the\x20buyer':'')+'\x20(escrow\x20+\x20compensation\x20stacked\x20on\x20the\x20same\x20order).\x0a\x0a'+KEEPER_DUAL_PAYOUT_DIRECTIVE}],'structuredContent':{'result':{'type':'error','error':'Order\x20'+dx['object']+'\x20carries\x20a\x20recorded\x20arbitration\x20indemnity\x20award\x20(claimed_by='+dx['claimed_by']+');\x20releasing\x20its\x20escrow\x20stacks\x20both\x20independent\x20payout\x20tracks\x20on\x20one\x20order'+(dg['track']==='order-directed'?'\x20(allocation\x20pays\x20order-directed\x20recipients)':'')+'\x20—\x20a\x20netting\x20decision\x20reserved\x20for\x20the\x20operator\x20via\x20acknowledge_dual_payout.','error_code':'dual_payout_unconfirmed','retryable':![],'recovery_hint':'The\x20two\x20payout\x20tracks\x20are\x20independent\x20by\x20design:\x20the\x20chain\x20never\x20nets\x20them\x20and\x20the\x20escrow\x20receive\x20path\x20has\x20no\x20claimed_by\x20gate\x20—\x20but\x20if\x20this\x20service\x27s\x20rails\x20use\x20the\x20claimed_by\x20pairing\x20(refund\x20rail\x20claimed_by\x20none\x20/\x20paired\x20recover\x20rail\x20claimed_by\x20some),\x20the\x20on-chain\x20guard\x20may\x20REJECT\x20this\x20alloc\x20(guard_rejected);\x20that\x20rejection\x20IS\x20the\x20pairing\x20working,\x20and\x20the\x20escrow\x20exits\x20via\x20the\x20paired\x20rail\x20instead.\x20Re-send\x20the\x20SAME\x20call\x20with\x20acknowledge_dual_payout:true\x20ONLY\x20if\x20this\x20distribution\x20is\x20an\x20intentional\x20commercial\x20decision\x20(buyer\x20NET\x20=\x20compensation\x20+\x20escrow\x20refund).\x20If\x20this\x20is\x20a\x20plain\x20refund\x20of\x20an\x20un-awarded\x20order,\x20the\x20order\x20you\x20submitted\x20is\x20the\x20wrong\x20one\x20—\x20verify\x20the\x20order\x20address\x20before\x20retrying.\x20'+KEEPER_DUAL_PAYOUT_DIRECTIVE},'message':'Refused:\x20this\x20release\x20would\x20stack\x20an\x20escrow\x20release\x20on\x20top\x20of\x20a\x20recorded\x20arbitration\x20indemnity\x20award.\x20Set\x20acknowledge_dual_payout:true\x20to\x20accept\x20explicitly\x20(HUMAN\x20operator\x20decision\x20—\x20keepers\x20must\x20escalate,\x20never\x20self-ack).'}};}if(de&&!df['authorized'])return{'content':[{'type':'text','text':'DUAL\x20PAYOUT\x20REFUSED\x20(preauthorization\x20missing)\x20—\x20no\x20transaction\x20was\x20sent.\x20Order\x20'+dx['object']+'\x20carries\x20a\x20recorded\x20arbitration\x20indemnity\x20award\x20(claimed_by='+dx['claimed_by']+')\x20and\x20this\x20alloc_by_guard\x20would\x20ALSO\x20release\x20its\x20escrow,\x20but\x20acknowledge_dual_payout\x20is\x20honored\x20ONLY\x20for\x20a\x20store\x20whose\x20human\x20merchant\x20recorded\x20the\x20standing\x20netting\x20decision\x20(config_operation\x20store_dual_payout_set\x20{account,\x20confirm:true});\x20the\x20executing\x20account\x20'+(df['account']??'(unresolved)')+'\x20has\x20none.\x0a\x0a'+KEEPER_DUAL_PAYOUT_DIRECTIVE}],'structuredContent':{'result':{'type':'error','error':'acknowledge_dual_payout\x20on\x20Order\x20'+dx['object']+'\x20requires\x20a\x20store-level\x20dual-payout\x20preauthorization\x20for\x20account\x20'+(df['account']??'(unresolved)')+'\x20—\x20the\x20per-call\x20flag\x20alone\x20is\x20the\x20self-ack\x20form\x20D-1\x20retired\x20(a\x20synthetic-store\x20agent\x20set\x20it\x20for\x20itself\x20in\x20the\x20ksr\x20round).','error_code':'dual_payout_preauthorization_required','retryable':![],'recovery_hint':'The\x20human\x20merchant\x20records\x20the\x20standing\x20netting\x20decision\x20ONCE\x20per\x20store\x20via\x20config_operation\x20store_dual_payout_set\x20{account:\x20<store\x20signing\x20account>,\x20confirm:\x20true,\x20note};\x20after\x20that\x20the\x20SAME\x20call\x20with\x20acknowledge_dual_payout:true\x20proceeds.\x20Automated\x20agents\x20must\x20NEVER\x20record\x20the\x20preauthorization\x20themselves\x20—\x20that\x20confirmation\x20is\x20the\x20human\x27s,\x20escalate\x20instead.\x20'+KEEPER_DUAL_PAYOUT_DIRECTIVE},'message':'Refused:\x20acknowledge_dual_payout\x20requires\x20the\x20store-level\x20preauthorization\x20(D-1).\x20The\x20merchant\x20records\x20it\x20via\x20config_operation\x20store_dual_payout_set\x20{account,\x20confirm:true};\x20automated\x20agents\x20escalate\x20instead\x20of\x20recording\x20it\x20themselves.'}};h['push']('DUAL\x20PAYOUT\x20ACKNOWLEDGED:\x20Order\x20'+dx['object']+'\x20carries\x20a\x20recorded\x20arbitration\x20indemnity\x20award\x20'+('(claimed_by='+dx['claimed_by']+';\x20compensation-fund\x20claim\x20state\x20per\x20the\x20Arb\x20case)\x20and\x20this\x20call\x20ALSO\x20releases\x20its\x20escrow'+(dg['track']==='entity-directed'?'\x20to\x20fixed\x20entity\x20recipients\x20('+dg['recipients']['join'](',\x20')+')':'')+'\x20—\x20verify\x20the\x20net\x20payout\x20per\x20party\x20is\x20the\x20intended\x20commercial\x20outcome.\x20Proceeding\x20on\x20the\x20explicit\x20acknowledge_dual_payout\x20flag\x20backed\x20by\x20the\x20store-level\x20preauthorization'+(df['authorized_at']?'\x20recorded\x20'+df['authorized_at']:'')+'\x20(D-1).'));}}}catch{}}if(c['data']?.['allocators']){const dB=await checkEntityRecipientGate(c['data']?.['allocators'],'allocation.allocators',h);if(dB)return dB;}let d2='';const d3=new CallAllocation(c['data']);c['data']?.['alloc_by_guard']&&(d2=beginInFlight('alloc_by_guard',c['data'],l,c['submission']));const d4=c['submission']?await d3['call_with_submission'](l,await transformSubmission(c['submission'])):await d3['call'](l);if(d2)recordInFlightOutcome(d2,d4);const d5=await buildGuardSubmissionPrompt(d4,'allocation',{'network':l?.['network'],'signer':l?.['account'],'allocation_address':c['data']?.['object']});if(d5)h['push'](d5);const d6=c['data'];if(d6?.['alloc_by_guard']){const dC=ResponseData(d4)['filter'](dD=>dD?.['type']==='Payment'&&dD?.['change']==='created');if(dC['length']>0x0){const dD=dC['map'](dE=>dE['object'])['join'](',\x20');try{const dE=await batchQueryObjectsByIds(dC['map'](dJ=>dJ['object']),l?.['network'],!![]),dF=[];let dG=BigInt(0x0);const dH=[];let dI=![];for(const dJ of dE){if(dJ?.['type']==='Payment'&&dJ?.['record']){for(const dK of dJ['record']){const dL=formatRecipientLabel(dK['recipient']),dM=typeof dK['amount']==='string'?dK['amount']:String(dK['amount']),dN=BigInt(dM);dG+=dN,dF['push']('\x20\x20•\x20'+dL+':\x20'+formatMistAmount(dN));const dO=classifyRecipient(dK['recipient']);if(dO?.['kind']==='entity'&&l?.['account']&&dO['address']['toLowerCase']()===String(l['account'])['toLowerCase']())dI=!![],dH['push']('\x20\x20•\x20'+dL+':\x20ALREADY\x20SPENDABLE\x20by\x20you\x20(caller\x20==\x20recipient,\x20auto-unwrapped\x20in\x20this\x20transaction\x20—\x20no\x20claim\x20step;\x20a\x20follow-up\x20payment\x20receive\x20will\x20correctly\x20report\x20no\x20pending\x20claim)');else{if(dO?.['kind']==='submission')dH['push']('\x20\x20•\x20'+dL+':\x20the\x20ORDER\x20OWNER\x20receives\x20—\x20call\x20the\x20order\x27s\x20receive/claim\x20entry');else{if(dO?.['kind']==='signer')dH['push']('\x20\x20•\x20'+dL+':\x20the\x20CALLER\x20receives\x20—\x20payment\x20receive\x20as\x20the\x20caller');else dO?.['kind']==='entity'?dH['push']('\x20\x20•\x20'+dL+':\x20that\x20account\x20receives\x20—\x20payment\x20receive\x20as\x20'+formatRecipientLabel(dK['recipient'])):dH['push']('\x20\x20•\x20'+dL+':\x20query\x20the\x20Payment\x20object\x27s\x20record\x20for\x20the\x20claim\x20path');}}}dJ['object']&&dF['push']('\x20\x20•\x20Payment\x20object:\x20'+dJ['object']);}}if(dF['length']>0x0){dF['unshift']('DISTRIBUTION\x20DETAILS\x20(alloc_by_guard):'),dF['push']('\x20\x20─────────────────','\x20\x20•\x20Total\x20distributed:\x20'+formatMistAmount(dG));const dP=dE['some'](dQ=>dQ?.['type']==='Payment'&&dQ?.['info']?.['for_object']);dP&&(dG===BigInt(0x0)?dF['push']('','ESCROW\x20MODE\x20(nothing\x20owed):\x20total\x20distributed\x20is\x200\x20—\x20'+'nothing\x20is\x20being\x20held\x20for\x20claiming\x20and\x20no\x20distribution\x20is\x20pending.'):dF['push']('','ESCROW\x20MODE:\x20funds\x20are\x20held\x20in\x20the\x20Payment\x20wrapper(s)\x20above\x20'+'(Payment.for_object\x20points\x20to\x20an\x20Order)\x20—\x20claim\x20entry\x20PER\x20ROW:',...dH,'Note:\x20the\x20slot\x20number\x20shown\x20per\x20row\x20is\x20that\x20rail\x27s\x20DECLARED\x20'+'GuardIdentifier\x20(a\x20254\x20rail\x20legitimately\x20shows\x20254)\x20—\x20do\x20NOT\x20'+'infer\x20slot\x200\x20from\x20this\x20receipt.'),dI&&dF['push']('AUTO-CLAIMED\x20(SDK\x20hidden\x20step):\x20at\x20least\x20one\x20row\x20had\x20caller\x20==\x20recipient\x20—\x20'+'that\x20share\x20was\x20unwrapped\x20inside\x20THIS\x20transaction\x20and\x20is\x20already\x20spendable;\x20'+'no\x20claim\x20step\x20remains.\x20A\x20follow-up\x20receive\x20reporting\x20'+'\x22already\x20unwrapped\x20or\x20auto-claimed\x22\x20is\x20the\x20EXPECTED\x20post-settlement\x20state,\x20not\x20a\x20failure.')),h['push'](dF['join']('\x0a'));}}catch{h['push']('alloc_by_guard\x20created\x20Payment\x20object(s)\x20['+dD+'].\x20'+'Query\x20these\x20Payment\x20objects\x20to\x20see\x20the\x20distribution\x20details\x20and\x20check\x20for_object\x20for\x20escrow\x20mode.');}}else l?.['dry_run']===!![]?h['push']('DRY\x20RUN\x20(alloc_by_guard\x20'+d6['alloc_by_guard']+'):\x20simulation\x20succeeded.\x20'+'No\x20Payment\x20objects\x20exist\x20because\x20dry\x20runs\x20materialize\x20nothing\x20—\x20this\x20is\x20NOT\x20a\x20'+'\x22nothing\x20distributed\x22\x20signal.\x20Evaluate\x20the\x20sharing\x20plan\x20from\x20the\x20dry-run\x20balance\x20'+'output\x20above;\x20re-run\x20without\x20dry_run\x20to\x20execute.'):h['push']('NOTHING\x20DISTRIBUTED\x20(alloc_by_guard\x20'+d6['alloc_by_guard']+'):\x20the\x20transaction\x20'+'succeeded\x20but\x20created\x20NO\x20Payment\x20object,\x20so\x20no\x20funds\x20moved.\x20'+'The\x20guard\x20is\x20bound\x20to\x20this\x20allocation,\x20so\x20this\x20is\x20not\x20a\x20wrong-guard\x20mistake\x20—\x20the\x20'+'distribution\x20evaluated\x20to\x20zero.\x20Usual\x20causes:\x20the\x20sharing\x20plan\x20computes\x200\x20for\x20the\x20'+'remaining\x20balance,\x20the\x20pool\x20is\x20already\x20fully\x20distributed,\x20or\x20the\x20guard\x27s\x20once-slot\x20'+'was\x20already\x20consumed.\x20Do\x20NOT\x20report\x20this\x20allocation\x20as\x20executed.');}const d7=handleCallResult(d4,x(c['data']));return k(y,z,c['operation_type'],d4,c['data'])['catch'](()=>{}),d7;}case'permission':{const dQ=c['operation_type'],dR=handlePermissionOperations(c['data'],l,x,h);return dR&&typeof dR==='object'&&'then'in dR&&dR['then'](dS=>{dS?.['structuredContent']?.['result']&&k(y,z,dQ,dS['structuredContent']['result'],c['data'])['catch'](()=>{});})['catch'](()=>{}),dR;}case'guard':{const dS=c['data'],dT=dS['root'];if(dT?.['type']==='file'){const dY=dT,dZ=resolve(dY['file_path']);let e0;try{e0=readFileSync(dZ,'utf-8');}catch(e3){throw new Error('Failed\x20to\x20read\x20Guard\x20definition\x20file\x20\x27'+dY['file_path']+'\x27:\x20'+e3['message']);}const e1=parseGuardFile(e0,dY['format']);if(!e1['success']){const e4=formatGuardParseErrors(e1['errors']);throw new Error('Guard\x20validation\x20failed\x20for\x20file\x20\x27'+dY['file_path']+'\x27:\x0a\x0a'+e4);}const e2=e1['data'];dS['root']={'type':'node','node':e2['root']},e2['table']!==undefined&&dS['table']===undefined&&(dS['table']=e2['table']),e2['description']!==undefined&&dS['description']===undefined&&(dS['description']=e2['description']),e2['rely']!==undefined&&dS['rely']===undefined&&(dS['rely']=e2['rely']),e2['namedNew']!==undefined&&dS['namedNew']===undefined&&(dS['namedNew']=e2['namedNew']);}if(dS['root']&&typeof dS['root']==='object'){const e5=dS['root'];e5['type']==='node'&&e5['node']&&(dS['root']=e5['node']);}if(!dS['table']||dS['table']['length']===0x0)throw new Error('Guard\x20\x27table\x27\x20field\x20is\x20required\x20and\x20cannot\x20be\x20empty');if(!dS['root'])throw new Error('Guard\x20\x27root\x27\x20field\x20is\x20required');const dU=dS['table']['filter'](e6=>e6['b_submission']===![]&&Array['isArray'](e6['value'])&&e6['value']['length']===0x0);if(dU['length']>0x0)throw new Error('Guard\x20creation\x20blocked:\x20static\x20table\x20slot(s)\x20'+dU['map'](e6=>e6['identifier'])['join'](',\x20')+'\x20'+'carry\x20an\x20EMPTY\x20array\x20value.\x20Guard\x20table\x20construction\x20silently\x20DROPS\x20empty\x20vectors\x20—\x20these\x20rows\x20would\x20be\x20'+'MISSING\x20from\x20the\x20created\x20Guard\x20while\x20creation\x20still\x20succeeds.\x20Give\x20each\x20slot\x20a\x20non-empty\x20static\x20value,\x20'+'or\x20flip\x20it\x20to\x20b_submission=true\x20and\x20supply\x20the\x20value\x20at\x20Guard\x20trigger\x20time\x20'+'(protocol\x20once-slots:\x20255\x20keys\x20on\x20the\x20submitted\x20bytes,\x20254\x20on\x20the\x20chain-derived\x20object\x20key).');try{const e6=lintGuardNodeGates(parseGuardNodeGates(dS['root'],dS['table']));if(e6)h['push'](e6);}catch{}try{const e7=Array['isArray'](dS['table'])?dS['table']:[],e8=dS['binding_hint'],e9=parseGuardNodeGates(dS['root'],dS['table']),ea=e9['some'](ee=>REFUND_RAIL_NODE_REGEX['test'](ee)),eb=e7['some'](ee=>{const ef=ee;return Number(ef?.['identifier'])===0x0&&ef?.['b_submission']===!![];}),ec=e8?.['action']==='allocate'||e8?.['binding_field']==='order_allocators',ed=lintTaskBindingAdvisories({'guardRef':dS['namedNew']?.['name'],'table':e7,'allocatorBound':!ea&&(ec||eb),'refundReentry':ea});for(const ee of ed){h['push'](formatTaskBindingAdvisory(ee,'guard\x20create'));}}catch{}try{const ef=[],eg=eh=>{if(!eh||typeof eh!=='object')return;const ei=eh;if(ei['type']==='query'&&typeof ei['query']==='number'){const ej=getGuardQueryByIdOrName(ei['query']);ef['push']('query('+ei['query']+')\x20->\x20\x27'+(ej?.['name']??'NOT\x20IN\x20CATALOG')+'\x27');}for(const ek of['parameters','nodes']){const el=ei[ek];if(Array['isArray'](el))el['forEach'](eg);}};eg(dS['root']),ef['length']>0x0&&h['push']('NUMERIC\x20QUERY\x20ID\x20RESOLUTION\x20(rndb58d8d\x20A2\x20—\x20verify\x20BEFORE\x20the\x20immutable\x20create):\x20'+(ef['join'](';\x20')+'.\x20A\x20numeric\x20ID\x20is\x20resolved\x20VERBATIM\x20at\x20runtime:\x20if\x20any\x20resolution\x20')+'above\x20is\x20NOT\x20the\x20field\x20you\x20intended,\x20STOP\x20and\x20rebuild\x20—\x20Guards\x20are\x20immutable,\x20and\x20a\x20'+'wrong-but-existing\x20ID\x20silently\x20checks\x20a\x20different\x20field\x20(it\x20only\x20fails\x20at\x20trigger\x20time,\x20'+'abort\x207,\x20without\x20naming\x20the\x20leg).\x20Prefer\x20the\x20NAMED\x20form\x20(e.g.\x20\x27order.amount\x27):\x20a\x20wrong\x20'+'name\x20fails\x20loudly\x20at\x20validation\x20instead\x20of\x20creating\x20a\x20mis-wired\x20Guard.');}catch{}const dV=new CallGuard(dS);let dW;try{dW=await dV['call'](l);}catch(eh){const ei=eh instanceof Error?eh['message']:String(eh),ej=translateGuardTypeError(ei);throw ej?new Error(ej):eh;}if(dW&&typeof dW==='object'&&'digest'in dW&&dW?.['effects']?.['status']?.['status']==='success'){try{const ek=ResponseData(dW)['filter'](em=>em['change']==='created'&&typeof em['type_raw']==='string'&&em['type_raw']['includes']('::guard::'))['map'](em=>String(em['object']))[0x0],el=dS['namedNew']?.['name'];console['warn']('[ConfirmGate]\x20guard\x20created\x20—\x20name='+(el??'<unnamed>')+(ek!==undefined?'\x20address='+ek:'')+('\x20digest='+(dW['digest']??'?')));}catch{}try{const em=dS['root']?.['type']??'<unknown>',en=Array['isArray'](dS['table'])?dS['table']:[],eo=en['length'],ep=en['filter'](ev=>ev?.['b_submission']===!![])['length'],eq=dS['rely']?.['guards'],er=Array['isArray'](eq)?eq['length']:0x0,es=dS['rely']?.['logic_or']===!![]?'OR':dS['rely']?.['logic_or']===![]?'AND':'none',et=['GUARD\x20LOGIC\x20SUMMARY:','\x20\x20•\x20root\x20type:\x20'+em,'\x20\x20•\x20table\x20entries:\x20'+eo+'\x20('+ep+'\x20require\x20runtime\x20submission)'],eu=en['filter'](ev=>ev?.['b_submission']===!![]);for(const ev of eu){const ew=typeof ev?.['value_type']==='string'?ev['value_type']:String(ev?.['value_type']??'?');et['push']('\x20\x20•\x20submission\x20slot\x20'+ev?.['identifier']+':\x20value_type='+ew+'\x20—\x20forwards\x20bound\x20to\x20this\x20Guard\x20'+('must\x20advance\x20with\x20submissions:[{identifier:'+ev?.['identifier']+',\x20value_type:\x22'+ew+'\x22}]\x20')+'(Address\x20slots:\x20pass\x20the\x20Order\x20object\x20address)');}er>0x0&&et['push']('\x20\x20•\x20relies\x20on:\x20'+er+'\x20guard(s)\x20(mode:\x20'+es+')');if(dS['description']){const ex=String(dS['description'])['slice'](0x0,0x50);et['push']('\x20\x20•\x20description:\x20\x22'+ex+'\x22');}h['push'](et['join']('\x0a'));}catch{}try{const ey=parseGuardTimeBounds(dS['root'],dS['table']);if(ey){const ez=[],eA=dS['namedNew']?.['name'];typeof eA==='string'&&eA['trim']()&&ez['push'](eA['trim']());try{const eC=ResponseData(dW)['filter'](eD=>eD['change']==='created'&&eD['object']&&typeof eD['type_raw']==='string'&&eD['type_raw']['includes']('::guard::'))['map'](eD=>String(eD['object']));ez['push'](...eC);}catch{}if(ez['length']>0x0)recordGuardTimeProfile(ez,ey);const eB=ey['upperWindowMs']!==undefined?'Clock\x20<=\x20'+ey['anchor']+'\x20+\x20'+ey['upperWindowMs']+'ms':'Clock\x20>=\x20'+ey['anchor']+'\x20+\x20'+ey['lowerOffsetMs']+'ms';h['push']('TIME\x20ANCHOR:\x20this\x20Guard\x20uses\x20'+eB+'.\x20'+(ey['anchor']==='order.time'?'order.time\x20anchor\x20=\x20ORDER\x20CREATION\x20time\x20—\x20upper\x20windows\x20on\x20POST-checkout\x20branches\x20must\x20instead\x20anchor\x20progress.current_time\x20(query\x201272,\x20OrderProgress\x20witness),\x20otherwise\x20the\x20window\x20may\x20expire\x20before\x20the\x20branch\x20is\x20reachable\x20(§5.5\x20dead\x20branch).\x20':'witness-derived\x20anchor\x20—\x20the\x20window\x20counts\x20from\x20entering\x20the\x20source\x20node\x20(serves\x20all\x20orders).\x20')+'The\x20Machine-side\x20reachability\x20check\x20will\x20cross-verify\x20when\x20these\x20Guards\x20are\x20bound\x20to\x20forwards.');}}catch{}try{const eD=ResponseData(dW)['filter'](eE=>eE['change']==='created'&&typeof eE['type_raw']==='string'&&eE['type_raw']['includes']('::guard::'))['map'](eE=>String(eE['object']));for(const eE of eD){const eF=await loadGuardJsonFromChain(eE,l?.['network']);if(!eF)continue;const eG=diffGuardSpecVsChain({'table':dS['table'],'root':dS['root'],'rely':dS['rely']},eF['json']);h['push'](eG['summary']);}}catch{}}const dX=handleCallResult(dW,x(c['data']));return k(y,z,c['operation_type'],dW,c['data'])['catch'](()=>{}),dX;}case'personal':{const eH=transformPersonalInput(c['data']),eI=new CallPersonal(eH),eJ=await eI['call'](l),eK=handleCallResult(eJ,x(c['data']));return k(y,z,c['operation_type'],eJ,c['data'])['catch'](()=>{}),eK;}case'payment':{const eL=await prepareFundOperation(c['data'],'payment',l?.['network']);if(eL['blockingErrors']['length']>0x0)return buildFundBlockResult(eL,'payment');h['push'](...eL['warnings']);if(eL['confirmation']){h['push'](eL['confirmation']['message']);const eQ=a523b(eL['confirmation']);if(eQ)h['push'](eQ);}const eM=c['data'];if(eM?.['receive']===!![]){const eR=typeof eM?.['object']==='string'&&eM['object']['length']>0x0;h['push']('RECEIVE\x20MODE\x20(order_claim):\x20You\x20are\x20unwrapping\x20CoinWrapper(s)\x20to\x20your\x20wallet.\x20'+'This\x20is\x20the\x20final\x20step\x20of\x20the\x20escrow\x20flow:\x0a'+'\x20\x201.\x20Allocation\x27s\x20alloc_by_guard\x20created\x20a\x20Payment\x20object\x20with\x20your\x20address\x20as\x20a\x20recipient\x0a'+'\x20\x202.\x20The\x20Payment\x27s\x20revenue\x20split\x20transferred\x20CoinWrapper(s)\x20to\x20your\x20wallet\x20(owned\x20but\x20not\x20spendable)\x0a'+'\x20\x203.\x20'+(eR?'THIS\x20operation\x20unwraps\x20the\x20specified\x20CoinWrapper\x20to\x20your\x20wallet':'AUTO-RECEIVE:\x20this\x20operation\x20unwraps\x20EVERY\x20CoinWrapper\x20currently\x20owned\x20by\x20you\x20in\x20a\x20single\x20transaction')+',\x20deleting\x20the\x20CoinWrapper(s)\x20and\x20transferring\x20the\x20underlying\x20coin\x20to\x20tx_context::sender\x0a'+'Requirements:\x0a'+'\x20\x20-\x20You\x20MUST\x20be\x20the\x20CoinWrapper\x27s\x20owner\x20(the\x20recipient\x20specified\x20in\x20the\x20Allocation)\x0a'+'\x20\x20-\x20type_parameter\x20is\x20OPTIONAL:\x20when\x20omitted\x20it\x20is\x20auto-derived\x20from\x20the\x20CoinWrapper\x27s\x20'+'own\x20on-chain\x20type\x20(the\x20inner\x20T\x20of\x20CoinWrapper<T>)\x0a'+(eR?'\x20\x20-\x20object\x20can\x20be\x20a\x20CoinWrapper\x20ID\x20(0x...)\x20or\x20a\x20local\x20mark\x20name\x0a':'\x20\x20-\x20When\x20\x27object\x27\x20is\x20omitted,\x20no\x20wrapper\x20lookup\x20is\x20needed\x20—\x20all\x20your\x20CoinWrappers\x20are\x20unwrapped\x20at\x20once\x0a')+'To\x20find\x20received\x20CoinWrappers:\x20call\x20query_toolkit\x20with\x20query_type=\x27onchain_received\x27\x20'+'and\x20type=\x27CoinWrapper\x27\x20for\x20your\x20account.\x0a'+'After\x20success:\x20verify\x20your\x20balance\x20increased\x20via\x20account_balance\x20query.');}else{if(eM?.['revenue']){h['push']('CREATE\x20MODE:\x20Creating\x20a\x20new\x20Payment\x20object.\x20Payments\x20are\x20IMMUTABLE\x20after\x20creation\x20—\x20'+'they\x20cannot\x20be\x20modified.\x20The\x20\x27revenue\x27\x20array\x20defines\x20the\x20recipients\x20and\x20amounts;\x20'+'ensure\x20correctness\x20before\x20submitting.\x20The\x20\x27info.for_guard\x27\x20field\x20(if\x20set)\x20binds\x20this\x20'+'Payment\x20to\x20a\x20Guard\x20for\x20conditional\x20release\x20(common\x20in\x20escrow\x20workflows).');for(let eT=0x0;eT<eM['revenue']['length'];eT++){const eU=eM['revenue'][eT],eV=classifyRecipient(eU?.['recipient']),eW=eV?.['kind']==='entity'?eV['address']:undefined;if(!eW||!isValidWowAddress(eW))continue;if(objectTypeFromAddress(eW)!==ObjectType['Allocation'])continue;const eX=eU?.['amount']?.['balance'];h['push']('P0\x20ALLOCATION-RECIPIENT\x20LEG\x20(irreversible\x20stranding):\x20revenue\x20leg\x20'+eT+'\x20sends\x20'+((eX!=null?String(eX):'(unspecified\x20amount)')+'\x20to\x20Allocation\x20'+eW+'.\x20')+'A\x20plain\x20payment\x20delivers\x20the\x20CoinWrapper\x20OWNED\x20BY\x20the\x20Allocation\x20object\x20itself,\x20and\x20'+'no\x20allocation\x20entry\x20can\x20ever\x20unwrap\x20it\x20—\x20these\x20funds\x20have\x20NO\x20user-triggerable\x20exit\x20'+'(verified\x20precedent:\x200.01\x20permanently\x20frozen\x20inside\x20Allocation\x200x1dcf3f3a…).\x20'+'To\x20fund\x20an\x20Allocation\x27s\x20pool,\x20use\x20the\x20renewal\x20intake\x20instead\x20'+'(create\x20the\x20escrowed\x20payment\x20record,\x20have\x20the\x20allocation\x20receive\x20it,\x20then\x20create\x20the\x20payment\x20in\x20ONE\x20PTB).\x20'+'To\x20pay\x20a\x20beneficiary,\x20target\x20a\x20user\x20account\x20or\x20an\x20object\x20with\x20its\x20own\x20receive\x20entry\x20'+'(Order/Treasury).\x20Confirm\x20this\x20is\x20intentional\x20before\x20submitting\x20—\x20this\x20cannot\x20be\x20undone.');}const eS=eM?.['object']?.['type_parameter']??'0x2::wow::WOW';for(const eY of eM['revenue']){const eZ=eY?.['amount'];if(eZ&&typeof eZ==='object'&&typeof eZ['balance']==='string'){const f0=await parseAmount(eZ['balance'],eS,l?.['network']);f0?.['smallestUnit']!=null&&(eZ['balance']=f0['smallestUnit']<=BigInt(Number['MAX_SAFE_INTEGER'])?Number(f0['smallestUnit']):f0['smallestUnit']['toString']());}}}}const eN=new CallPayment(c['data']);let eO;try{eO=await eN['call'](l);}catch(f1){const f2=f1 instanceof Error?f1['message']:String(f1);if(/is not a CoinWrapper/i['test'](f2)&&/already unwrapped or auto-claimed/i['test'](f2)){const f3=typeof c['data']?.['object']==='string'?c['data']['object']:'(unknown)';return{'content':[{'type':'text','text':'No\x20live\x20CoinWrapper\x20at\x20'+f3+'\x20—\x20this\x20id\x20is\x20NOT\x20proof\x20of\x20arrival,\x20and\x20this\x20receive\x20is\x20a\x20no-op.\x20'+'Two\x20possible\x20states,\x20discriminate\x20BEFORE\x20reporting\x20anything\x20to\x20anyone:\x20'+'(a)\x20CLAIMED:\x20it\x20was\x20a\x20CoinWrapper\x20already\x20unwrapped/claimed\x20—\x20funds\x20are\x20spendable\x20in\x20the\x20wallet;\x20'+'(b)\x20WRONG\x20ID:\x20it\x20is\x20a\x20Payment\x20(or\x20other\x20non-wrapper\x20object)\x20—\x20a\x20settlement\x20Payment\x20holds\x20'+'per-recipient\x20CoinWrappers\x20that\x20must\x20be\x20claimed\x20INDIVIDUALLY,\x20and\x20unclaimed\x20wrappers\x20hold\x20the\x20funds.\x20'+'Discriminate\x20with\x20query_toolkit\x20onchain_received\x20(lists\x20unclaimed\x20wrappers\x20owned\x20by\x20the\x20signer\x20—\x20'+'any\x20wrapper\x20under\x20a\x20Payment\x20appears\x20here\x20until\x20claimed)\x20or\x20onchain_objects\x20on\x20the\x20id\x20to\x20read\x20its\x20type.\x20'+'Do\x20NOT\x20retry\x20the\x20same\x20receive\x20and\x20do\x20NOT\x20report\x20funds\x20as\x20arrived\x20on\x20this\x20response\x20alone.'}],'structuredContent':{'outcome':'executed','result':{'type':'null'},'message':'No\x20live\x20CoinWrapper\x20at\x20'+f3+':\x20either\x20already\x20claimed\x20(funds\x20spendable)\x20or\x20a\x20non-wrapper\x20id\x20such\x20as\x20a\x20Payment\x20whose\x20per-recipient\x20CoinWrappers\x20still\x20need\x20individual\x20claims\x20—\x20discriminate\x20via\x20onchain_received\x20before\x20reporting\x20arrival.','semantic':{'intent':'payment_receive','status':'success','summary':'No-op\x20receive\x20at\x20'+f3+':\x20not\x20a\x20live\x20wrapper.\x20Arrival\x20is\x20NOT\x20proven\x20—\x20check\x20for\x20unclaimed\x20per-recipient\x20wrappers\x20(onchain_received)\x20or\x20confirm\x20the\x20prior\x20claim\x20(account_balance).','next_actions':[{'action':'List\x20unclaimed\x20wrappers','reason':'If\x20a\x20Payment\x20id\x20was\x20passed,\x20its\x20per-recipient\x20CoinWrappers\x20are\x20the\x20real\x20claim\x20targets\x20and\x20may\x20still\x20hold\x20the\x20funds','tool':'query_toolkit','priority':'critical'},{'action':'Verify\x20the\x20arrival','reason':'Only\x20account_balance\x20/\x20onchain_received\x20prove\x20funds\x20arrived\x20—\x20this\x20no-op\x20response\x20does\x20not','tool':'account_operation','priority':'recommended'}],'warnings':['Receive\x20skipped\x20for\x20'+f3+':\x20no\x20live\x20CoinWrapper\x20remains\x20under\x20this\x20id.\x20This\x20response\x20is\x20NOT\x20proof\x20that\x20funds\x20arrived\x20—\x20a\x20Payment\x20id\x20means\x20the\x20per-recipient\x20wrappers\x20were\x20never\x20touched.']}}};}throw f1;}const eP=handleCallResult(eO,x(c['data']));return k(y,z,c['operation_type'],eO,c['data'])['catch'](()=>{}),eP;}case'demand':{const f4=new CallDemand(c['data']),f5=c['submission']?await f4['call_with_submission'](l,await transformSubmission(c['submission'])):await f4['call'](l),f6=await buildGuardSubmissionPrompt(f5,'demand',{'network':l?.['network'],'signer':l?.['account'],'extra':{'demand':c['data']?.['object']}});if(f6)h['push'](f6);const f7=handleCallResult(f5,x(c['data']));return k(y,z,c['operation_type'],f5,c['data'])['catch'](()=>{}),f7;}case'order':{c['data']?.['progress']&&(h['push']('Order\x20routing\x20fact:\x20order.progress\x20runs\x20the\x20order-bound\x20path\x20—\x20it\x20passes\x20'+'namedOperator=\x22\x22\x20forwards\x20for\x20the\x20order\x20payer/agents,\x20and\x20non-empty\x20'+'namedOperator\x20or\x20permissionIndex\x20forwards\x20for\x20senders\x20entitled\x20by\x20them\x20'+'(same\x20checks\x20as\x20the\x20Progress-level\x20path).\x20On\x20an\x20order-bound\x20Progress,\x20'+'workflow_operation\x20operate\x20auto-routes\x20to\x20this\x20same\x20path.'),h['push']('Allocation\x20hint:\x20if\x20this\x20operation\x20advances\x20the\x20order\x20to\x20a\x20terminal\x20'+'state\x20(e.g.\x20Completed/Cancelled/Refunded),\x20funds\x20remain\x20in\x20the\x20'+'Allocation\x20object\x20and\x20are\x20NOT\x20auto-distributed.\x20To\x20release\x20funds,\x20'+'trigger\x20the\x20corresponding\x20Guard\x20verification\x20via\x20allocation\x20operation\x20'+'(the\x20Guard\x20bound\x20to\x20the\x20matching\x20Allocator\x20will\x20verify\x20and\x20distribute).\x20'+'Refunds\x20are\x20TWO-STEP\x20(E-4):\x20the\x20refund\x20alloc\x20pays\x20into\x20the\x20ORDER\x20object\x20'+'(only\x20the\x20order\x20owner\x20can\x20extract)\x20—\x20after\x20the\x20alloc,\x20the\x20order\x20owner\x20'+'must\x20run\x20order\x20receive\x20(e.g.\x20receive:\x27recently\x27)\x20to\x20unwrap\x20to\x20the\x20wallet;\x20'+'treat\x20\x27cancelled/refunded\x20+\x20unclaimed\x20balance\x27\x20as\x20a\x20standard\x20pending\x20task.'));const f8=c['data']?.['arb_claim_compensation'];if(f8&&typeof c['data']?.['object']==='string')try{const fd=c['data']['object'],fe=fd['startsWith']('0x')?fd:await LocalMark['Instance']()['get_address'](fd)??undefined;if(fe){const ff=await query_objects({'objects':[fe],'no_cache':!![],'network':l?.['network']}),fg=ff?.['objects']?.[0x0],fh=fg?.['data']??fg,fi=fh?.['service'],fj=readRawOnchainAmount(fh?.['amount']);let fk;if(typeof fh?.['allocation']==='string'&&fh['allocation']['startsWith']('0x'))try{const fq=await query_objects({'objects':[fh['allocation']],'no_cache':!![],'network':l?.['network']}),fr=fq?.['objects']?.[0x0];fk=readRawOnchainAmount(fr?.['data']?.['balance']??fr?.['balance']);}catch{}const fl=c['data']?.['acknowledge_dual_payout']===!![];let fm;if(fi){const fs=await query_objects({'objects':[fi],'no_cache':!![],'network':l?.['network']}),ft=fs?.['objects']?.[0x0];fm=readRawOnchainAmount((ft?.['data']??ft)?.['compensation_fund']);}let fn;const fo=f8?.['arb'];if(typeof fo==='string'){const fu=fo['startsWith']('0x')?fo:await LocalMark['Instance']()['get_address'](fo)??undefined;if(fu){const fv=await query_objects({'objects':[fu],'no_cache':!![],'network':l?.['network']});fn=readRawOnchainAmount(fv?.['objects']?.[0x0]?.['data']?.['indemnity']);}}const fp=arbClaimEscrowEmptyDualPayout({'orderAmount':fj,'escrowBalance':fk,'poolValue':fm,'acknowledged':fl});if(fp==='refuse')return{'content':[{'type':'text','text':'DUAL\x20PAYOUT\x20REFUSED\x20—\x20no\x20transaction\x20was\x20sent.\x20Order\x20'+fe+'\x27s\x20escrow\x20is\x20ALREADY\x20FULLY\x20RELEASED\x20(allocation\x20balance\x200\x20of\x20'+fj+')\x20and\x20this\x20arb_claim_compensation\x20would\x20stack\x20the\x20arbitration\x20compensation'+(fn!==undefined?'\x20('+fn+'\x20raw\x20units)':'')+'\x20from\x20the\x20merchant-funded\x20pool\x20on\x20top\x20of\x20that\x20completed\x20escrow\x20track.\x0a\x0a'+KEEPER_DUAL_PAYOUT_DIRECTIVE}],'structuredContent':{'result':{'type':'error','error':'Order\x20'+fe+':\x20the\x20escrow\x20track\x20already\x20completed\x20(allocation\x20balance\x200\x20of\x20'+fj+')\x20and\x20this\x20claim\x20pays\x20the\x20arbitration\x20compensation\x20on\x20top\x20—\x20the\x20recipient\x27s\x20net\x20becomes\x20compensation\x20+\x20a\x20completed\x20escrow\x20track.\x20Confirm\x20the\x20netting\x20intent\x20before\x20the\x20chain\x20pays\x20the\x20second\x20track.','error_code':'dual_payout_unconfirmed','retryable':![],'recovery_hint':'The\x20escrow\x20track\x20and\x20the\x20compensation\x20track\x20are\x20independent\x20by\x20design:\x20the\x20chain\x20will\x20not\x20block\x20the\x20second\x20one,\x20though\x20a\x20rail\x20paired\x20on\x20order.claimed_by\x20may\x20guard-reject\x20the\x20post-claim\x20refund\x20leg\x20—\x20that\x20rejection\x20is\x20the\x20designed\x20mutual\x20exclusion,\x20not\x20a\x20malfunction.\x20State\x20the\x20decision\x20explicitly:\x20re-send\x20the\x20SAME\x20call\x20with\x20acknowledge_dual_payout:true\x20ONLY\x20if\x20paying\x20the\x20compensation\x20on\x20top\x20of\x20the\x20fully-released\x20escrow\x20is\x20the\x20intended\x20commercial\x20outcome\x20(e.g.\x20the\x20award\x20covers\x20a\x20loss\x20the\x20escrow\x20release\x20did\x20not).\x20If\x20the\x20escrow\x20release\x20already\x20settled\x20this\x20order,\x20do\x20not\x20claim\x20—\x20verify\x20the\x20order\x20address\x20before\x20retrying.\x20'+KEEPER_DUAL_PAYOUT_DIRECTIVE},'message':'Refused:\x20this\x20compensation\x20claim\x20would\x20stack\x20on\x20a\x20fully-released\x20escrow.\x20Set\x20acknowledge_dual_payout:true\x20to\x20accept\x20explicitly\x20(HUMAN\x20operator\x20decision\x20—\x20keepers\x20must\x20escalate,\x20never\x20self-ack).'}};if(fp==='acknowledged'){const fw=await storeDualPayoutVerdict(l);if(!fw['authorized'])return{'content':[{'type':'text','text':'DUAL\x20PAYOUT\x20REFUSED\x20(preauthorization\x20missing)\x20—\x20no\x20transaction\x20was\x20sent.\x20Order\x20'+fe+'\x27s\x20escrow\x20is\x20ALREADY\x20FULLY\x20RELEASED\x20(allocation\x20balance\x200\x20of\x20'+fj+')\x20and\x20this\x20arb_claim_compensation\x20would\x20stack\x20the\x20compensation\x20on\x20top,\x20but\x20acknowledge_dual_payout\x20is\x20honored\x20ONLY\x20for\x20a\x20store\x20whose\x20human\x20merchant\x20recorded\x20the\x20standing\x20netting\x20decision\x20(config_operation\x20store_dual_payout_set\x20{account,\x20confirm:true});\x20the\x20executing\x20account\x20'+(fw['account']??'(unresolved)')+'\x20has\x20none.\x0a\x0a'+KEEPER_DUAL_PAYOUT_DIRECTIVE}],'structuredContent':{'result':{'type':'error','error':'acknowledge_dual_payout\x20on\x20Order\x20'+fe+'\x20requires\x20a\x20store-level\x20dual-payout\x20preauthorization\x20for\x20account\x20'+(fw['account']??'(unresolved)')+'\x20—\x20the\x20per-call\x20flag\x20alone\x20is\x20the\x20self-ack\x20form\x20D-1\x20retired.','error_code':'dual_payout_preauthorization_required','retryable':![],'recovery_hint':'The\x20human\x20merchant\x20records\x20the\x20standing\x20netting\x20decision\x20ONCE\x20per\x20store\x20via\x20config_operation\x20store_dual_payout_set\x20{account:\x20<store\x20signing\x20account>,\x20confirm:\x20true,\x20note};\x20after\x20that\x20the\x20SAME\x20call\x20with\x20acknowledge_dual_payout:true\x20proceeds.\x20Automated\x20agents\x20must\x20NEVER\x20record\x20the\x20preauthorization\x20themselves\x20—\x20escalate\x20instead.\x20'+KEEPER_DUAL_PAYOUT_DIRECTIVE},'message':'Refused:\x20acknowledge_dual_payout\x20requires\x20the\x20store-level\x20preauthorization\x20(D-1).\x20The\x20merchant\x20records\x20it\x20via\x20config_operation\x20store_dual_payout_set\x20{account,\x20confirm:true};\x20automated\x20agents\x20escalate\x20instead\x20of\x20recording\x20it\x20themselves.'}};h['push']('DUAL\x20PAYOUT\x20ACKNOWLEDGED:\x20order\x20'+fe+'\x27s\x20escrow\x20is\x20already\x20fully\x20released\x20(allocation\x20balance\x200\x20of\x20'+fj+')\x20and\x20this\x20claim\x20pays\x20the\x20arbitration\x20compensation\x20on\x20top\x20—\x20proceeding\x20on\x20the\x20explicit\x20acknowledge_dual_payout\x20flag\x20backed\x20by\x20the\x20store-level\x20preauthorization'+(fw['authorized_at']?'\x20recorded\x20'+fw['authorized_at']:'')+'\x20(D-1);\x20verify\x20the\x20net\x20payout\x20per\x20party\x20is\x20the\x20intended\x20commercial\x20outcome.');}if(fm===0x0&&fn!==0x0)h['push']('COMPENSATION\x20POOL\x20EMPTY:\x20the\x20Service\x27s\x20compensation_fund\x20is\x200\x20—\x20this\x20claim\x20will\x20'+'abort\x20with\x20code\x2027\x20(E_COMPENSATION_NOT_MATCH).\x20The\x20abort\x20does\x20NOT\x20consume\x20the\x20claim\x20'+'(the\x20Arb\x20stays\x20Arbitrated):\x20the\x20merchant\x20must\x20top\x20up\x20via\x20service\x20'+'compensation_fund_add\x20(>=\x20the\x20ruled\x20indemnity),\x20then\x20re-run\x20arb_claim_compensation.');else{if(fm!==undefined&&fn!==undefined&&fm<fn)h['push']('COMPENSATION\x20POOL\x20UNDERFUNDED:\x20compensation_fund\x20('+fm+'\x20raw\x20units)\x20is\x20less\x20than\x20'+('the\x20ruled\x20indemnity\x20('+fn+'\x20raw\x20units)\x20—\x20the\x20claim\x20will\x20abort\x20with\x20code\x2027.\x20')+'Merchant\x20must\x20top\x20up\x20via\x20service\x20compensation_fund_add,\x20then\x20retry\x20(the\x20abort\x20does\x20'+'not\x20consume\x20the\x20claim).');else{if(fm!==undefined&&fj!==undefined&&fj>0x0&&fm<0x3*fj)h['push']('COMPENSATION\x20COVERAGE\x20BELOW\x20CEILING:\x20compensation_fund\x20('+fm+')\x20is\x20less\x20than\x20'+('3x\x20the\x20order\x20amount\x20('+fj+')\x20—\x20the\x20chain\x20caps\x20any\x20award\x20at\x203x\x20')+'(MAX_INDEMNITY_MULTIPLE,\x20arb.move),\x20so\x20a\x20ruling\x20at\x20the\x20ceiling\x20would\x20abort\x20this\x20'+'buyer\x27s\x20payout.\x20Recommend\x20the\x20merchant\x20top\x20up\x20the\x20pool\x20via\x20service\x20'+'compensation_fund_add.\x20(Above\x203x\x20only\x20buys\x20headroom\x20for\x20concurrent\x20claims\x20—\x20'+'the\x20pool\x20is\x20per-Service\x20and\x20has\x20no\x20on-chain\x20concurrency\x20limit.)');else fm!==undefined&&fm>0x0&&h['push']('Reminder:\x20this\x20claim\x20pays\x20from\x20the\x20Service\x27s\x20merchant-prepaid\x20compensation_fund\x20pool\x20'+'(not\x20the\x20order\x20escrow).\x20Pool\x20balance\x20is\x20sufficient\x20for\x20now.\x20A\x20settled\x20claim\x20does\x20NOT\x20'+'seal\x20the\x20order:\x20a\x20later\x20refund-track\x20alloc\x20can\x20still\x20split\x20AND\x20pay\x20out\x20the\x20escrow\x20'+'(the\x20owner\x20receive\x20entries\x20are\x20deliberately\x20ungated,\x20order.move:213-234)\x20—\x20enforce\x20'+'any\x20refund-vs-claim\x20exclusion\x20by\x20gating\x20the\x20refund\x20allocator\x20on\x20order.claimed_by\x20'+'some==false\x20at\x20configuration\x20time.\x20The\x20provider\x20release\x20track\x20(direct\x20transfer)\x20'+'stays\x20usable.');}}}}catch{}const f9=new CallOrder(c['data']),fa=c['submission']?await f9['call_with_submission'](l,await transformSubmission(c['submission'])):await f9['call'](l);if(c['data']?.['receive']!=null&&fa&&typeof fa==='object'&&fa?.['effects']?.['status']?.['status']==='success'){const fx=fa['effects'],fy=Array['isArray'](fx?.['objectChanges'])?fx['objectChanges']:Array['isArray'](fa?.['objectChanges'])?fa['objectChanges']:[],fz=fE=>String(fE??'')['includes']('::coin::Coin'),fA=fy['filter'](fE=>fE?.['type']==='created'&&fz(fE?.['objectType'])),fB=fy['filter'](fE=>fE?.['type']==='mutated'&&fz(fE?.['objectType'])),fC=Array['isArray'](fx?.['balanceChanges'])?fx['balanceChanges']:[],fD=fC['length']?'Balance\x20delta\x20this\x20tx:\x20'+fC['map'](fE=>{const fF=typeof fE?.['owner']==='object'&&fE?.['owner']!==null?String(fE['owner']['AddressOwner']??fE['owner']['ObjectOwner']??''):String(fE?.['owner']??'');return(fF||'(unknown)')+'\x20'+(fE?.['amount']??'?')+'\x20('+(String(fE?.['coinType']??'')['split']('::')['pop']()??'')+')';})['join'](';\x20'):'';h['push']('RECEIVE\x20RECEIPT:\x20claimed\x20'+fA['length']+'\x20object(s)\x20into\x20the\x20wallet'+(fA['length']?'\x20('+fA['map'](fE=>fE?.['objectId'])['join'](',\x20')+')':'')+(fD?'.\x20'+fD+'.':'')+(fB['length']?'\x20'+fB['length']+'\x20existing\x20coin(s)\x20consolidated/used\x20for\x20gas\x20(mutations,\x20NOT\x20new\x20funds).':'')+(fA['length']===0x0?'\x20NO_PENDING_CLAIM:\x20this\x20enumeration\x20found\x20nothing\x20claimable\x20—\x20a\x20coin\x20merge\x20may\x20still\x20have\x20run,\x20so\x20verify\x20arrival\x20on\x20the\x20AGGREGATE\x20balance\x20(account_balance),\x20never\x20on\x20created[].':'\x20A\x20claimed\x20refund\x20typically\x20arrives\x20as\x20its\x20OWN\x20Coin\x20object\x20—\x20the\x20balance\x20aggregate\x20may\x20show\x20it\x20as\x20a\x20second\x20coin,\x20so\x20consolidate\x20before\x20pricing\x20the\x20next\x20payment.'));}if(f8){const fE=!!fa&&typeof fa==='object'&&fa?.['effects']?.['status']?.['status']==='success';let fF;if(fE&&typeof c['data']?.['object']==='string')try{const fH=c['data']['object'],fI=fH['startsWith']('0x')?fH:await LocalMark['Instance']()['get_address'](fH)??undefined;let fJ;if(fI){const fK=await query_objects({'objects':[fI],'no_cache':!![],'network':l?.['network']}),fL=fK?.['objects']?.[0x0];fJ=(fL?.['data']??fL)?.['progress'];}fF=await autoHoldAfterClaim(l,fH,fJ);}catch{}const fG=['DUAL-TRACK\x20NOTICE\x20(NET\x20view):\x20claiming\x20compensation\x20does\x20NOT\x20adjust\x20the\x20allocation\x20—\x20'+'compensation\x20(Service\x20compensation_fund)\x20and\x20escrow\x20settlement\x20(Allocation)\x20are\x20independent\x20'+'tracks,\x20and\x20claim/objection\x20remain\x20mutually\x20exclusive\x20(claim\x20closes\x20the\x20case).\x20Buyer\x20NET\x20'+'across\x20BOTH\x20tracks\x20=\x20compensation\x20+\x20any\x20escrow\x20still\x20released\x20via\x20the\x20refund\x20track;\x20to\x20keep\x20'+'the\x20total\x20at\x20the\x20actual\x20loss,\x20keep\x20the\x20settlement\x20sealed\x20(auto-hold\x20below)\x20or\x20release\x20the\x20'+'escrow\x20only\x20through\x20acknowledge_dual_payout\x20on\x20the\x20alloc_by_guard\x20call.'];if(fF&&(fF['held']['length']||fF['notHoldable']['length']||fF['failed']['length']))fF['held']['length']&&fG['push']('Auto-hold\x20applied\x20to:\x20'+fF['held']['join'](',\x20')+'\x20—\x20a\x20courtesy\x20Progress\x20hold,\x20NOT\x20a\x20chain-level\x20freeze.\x20Forwards\x20may\x20still\x20be\x20executable\x20by\x20other\x20permissioned\x20operators\x20and\x20the\x20machine\x20keeps\x20advancing;\x20the\x20post-claim\x20fund\x20safety\x20is\x20structural\x20(a\x20second\x20payout\x20via\x20alloc\x20fails\x20—\x20allocator\x20claimed_by\x20leg),\x20not\x20a\x20settlement\x20freeze.'),fF['notHoldable']['length']&&fG['push']('NOT\x20holdable\x20by\x20this\x20account\x20(needs\x20merchant/keeper\x20to\x20run\x20order\x20hold):\x20'+fF['notHoldable']['join'](',\x20')+'.'),fF['failed']['length']&&fG['push']('Hold\x20attempted\x20but\x20failed\x20(retry,\x20or\x20have\x20merchant/keeper\x20hold\x20manually):\x20'+fF['failed']['join'](',\x20')+'.'),fF['held']['length']===0x0&&fG['push']('No\x20outgoing\x20edge\x20could\x20be\x20auto-held\x20—\x20the\x20escrow\x20settlement\x20track\x20is\x20STILL\x20OPEN;\x20'+'have\x20the\x20merchant/keeper\x20hold\x20the\x20edge(s)\x20above\x20before\x20the\x20order\x20reaches\x20completed.');else fE?fG['push']('No\x20outgoing\x20edge\x20to\x20freeze\x20at\x20the\x20current\x20node\x20(order\x20likely\x20at\x20a\x20terminal\x20node),\x20or\x20'+'edge\x20resolution\x20was\x20unavailable\x20—\x20verify\x20the\x20settlement\x20state\x20manually.'):fG['push']('The\x20claim\x20did\x20not\x20succeed,\x20so\x20no\x20hold\x20was\x20attempted;\x20rerun\x20after\x20fixing\x20the\x20cause\x20above.');h['push'](fG['join']('\x20'));if(fE&&typeof c['data']?.['object']==='string')try{const fM=c['data']['object'],fN=fM['startsWith']('0x')?fM:await LocalMark['Instance']()['get_address'](fM)??undefined;if(fN){const fO=await query_objects({'objects':[fN],'no_cache':!![],'network':l?.['network']}),fP=fO?.['objects']?.[0x0]?.['data']??fO?.['objects']?.[0x0],fQ=typeof fP?.['service']==='string'?fP['service']:undefined;if(fQ){const fR=await query_objects({'objects':[fQ],'no_cache':!![],'network':l?.['network']}),fS=fR?.['objects']?.[0x0]?.['data']??fR?.['objects']?.[0x0],fT=fS?.['compensation_fund'],fU=typeof fT==='string'&&/^\d+$/['test'](fT['trim']())?BigInt(fT['trim']()):typeof fT==='number'&&Number['isFinite'](fT)?BigInt(Math['trunc'](fT)):undefined;if(fU===0x0n){const fV=fundWaterReminder('depleted',{'balance':'0','threshold':'0'});if(fV)h['push'](fV);}else{if(fU!==undefined&&fU>0x0n&&Array['isArray'](fS?.['sales'])){const fW=fS['sales']['filter'](fY=>!fY?.['suspension']&&/^\d+$/['test'](String(fY?.['price']??'')['trim']()))['map'](fY=>({'name':String(fY?.['name']??''),'price':BigInt(String(fY['price'])['trim']())})),fX=computeFundListingWall(fU,fW);fX['walled']&&h['push']('FUND\x20LISTING\x20WALL\x20AFTER\x20AWARD:\x20this\x20claim\x20spent\x20the\x20Service\x27s\x20compensation\x20fund\x20—\x20the\x20live\x20fund\x20now\x20backs\x20single\x20orders\x20up\x20to\x20'+(fX['coverCap']['toString']()+'\x20base\x20units,\x20and\x20'+fX['blocked']['length']+'\x20listing(s)\x20are\x20priced\x20ABOVE\x20that\x20and\x20now\x20check\x20out\x20UNDER-COVERED\x20')+('(highest\x20first:\x20'+fX['blocked']['map'](fY=>fY['name']||'(unnamed)')['join'](',\x20')+').\x20The\x20order\x20still\x20proceeds\x20with\x20a\x20buy-time\x20warning\x20(拍板⑤\x20dm-mtw-261027\x20demoted\x20the\x20refusal),\x20')+'but\x20a\x20max-award\x20ruling\x20aborts\x20code\x2027\x20until\x20the\x20fund\x20is\x20topped\x20above\x203x\x20their\x20price\x20(service.compensation_fund_add)\x20or\x20the\x20price\x20is\x20cut.\x20'+'The\x20merchant\x20should\x20re-check\x20the\x20storefront\x20—\x20service_panorama\x20carries\x20the\x20live\x20wall\x20under\x20compensation_fund_listing_wall.');}}}}}catch{}}const fb=await buildGuardSubmissionPrompt(fa,'order',{'network':l?.['network'],'signer':l?.['account'],'order_address':c['data']?.['object']});if(fb)h['push'](fb);if(c['data']?.['order_new']&&fa&&typeof fa==='object'&&fa?.['effects']?.['status']?.['status']==='success'&&fa?.['digest']){const fY=await applyInitialForwardAfterOrderNew(c['data'],l);if(fY)h['push'](fY);}const fc=handleCallResult(fa,x(c['data']));if(fa&&typeof fa==='object'&&'digest'in fa&&fa?.['effects']?.['status']?.['status']==='success'&&c['data']?.['progress']&&typeof c['data']?.['object']==='string')try{const fZ=c['data']['object'],g0=fZ['startsWith']('0x')?fZ:await LocalMark['Instance']()['get_address'](fZ)??undefined;let g1;if(g0){const g2=await query_objects({'objects':[g0],'no_cache':!![],'network':l?.['network']}),g3=g2?.['objects']?.[0x0];g1=(g3?.['data']??g3)?.['progress'];}if(g1){const g4=c['data']['progress']?.['operation'],g5=await enrichWorkflowGuidance({'progressRef':g1,'network':l?.['network'],'accountName':l?.['account'],'noCache':!![],'txResult':fa,'dryRun':l?.['dry_run']===!![],'compact':l?.['response_level']!=='full','operate':g4?.['forward']&&g4?.['next_node_name']?{'forward':g4['forward'],'next_node_name':g4['next_node_name'],'op':c['data']['progress']?.['op']}:undefined});mergeGuidanceIntoOutput(fc,g5,{'responseLevel':l?.['response_level']});}}catch{}return k(y,z,c['operation_type'],fa,c['data'])['catch'](()=>{}),fc;}case'gen_passport':{const g6=await gen_passport(l,c['guard'],c['info']);let g7;try{const g9=Array['isArray'](g6?.['objectChanges'])?g6['objectChanges']:[],ga=g9['find'](gc=>gc?.['type']==='created'&&typeof gc?.['objectType']==='string'&&/::passport::Passport$/['test'](gc['objectType'])),gb=ga?.['objectId'];if(gb){const gc=await query_objects({'objects':[gb],'no_cache':!![],'network':l?.['network']}),gd=gc?.['objects']?.[0x0],ge=gd?.['data']??gd;ge&&typeof ge==='object'&&typeof ge['result']==='boolean'&&(g7={'passport_id':gb,'result':ge['result']===!![],'has_verified':ge['has_verified']===!![],'info':Array['isArray'](ge['guard'])?ge['guard']['map'](gf=>({'guard':String(gf?.['guard']??gf??''),'result':gf?.['result']===!![],...typeof gf?.['impack']==='boolean'?{'impack':gf['impack']}:{}})):undefined});}}catch{}const g8=handleCallResult(g6,x(c['data'],undefined,g7));try{for(const gf of c['guard']??[]){const gg=typeof gf==='string'?gf:gf?.['object'];if(typeof gg!=='string'||gg==='')continue;const gh=await loadGuardJsonFromChain(gg,l?.['network']);if(!gh)continue;const gi=(gh['json']['table']??[])['some'](gj=>gj?.['identifier']===TASK_BINDING_SLOT&&gj?.['b_submission']===!![]&&gj?.['value_type']==='Address');!gi&&h['push']('PROTOCOL\x20SLOT\x20'+TASK_BINDING_SLOT+'\x20MISSING\x20on\x20Guard\x20\x27'+(gh['name']??gh['guard'])+'\x27:\x20the\x20table\x20declares\x20no\x20{identifier:\x20'+TASK_BINDING_SLOT+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20row\x20(task\x20binding).\x20A\x20passport\x20built\x20now\x20can\x20never\x20satisfy\x20the\x20on-chain\x20task-binding\x20check\x20on\x20an\x20order-driven\x20Progress\x20forward\x20(abort\x20code\x2011)\x20—\x20the\x20passport\x20only\x20emits\x20DECLARED\x20table\x20rows.\x20Fix\x20BEFORE\x20binding/publishing:\x20export\x20the\x20guard\x20(guard2file),\x20add\x20the\x20'+TASK_BINDING_SLOT+'\x20declaration,\x20create\x20a\x20NEW\x20Guard,\x20and\x20rebind\x20—\x20tables\x20freeze\x20at\x20creation.');}}catch{}return k(y,z,c['operation_type'],g6,c['data'])['catch'](()=>{}),g8;}case'proof':{const gj=new CallProof(c['data']),gk=c['submission']?await gj['call_with_submission'](l,await transformSubmission(c['submission'])):await gj['call'](l),gl=await buildGuardSubmissionPrompt(gk,'proof',{'network':l?.['network'],'signer':l?.['account']});if(gl)h['push'](gl);const gm=handleCallResult(gk,x(c['data']));return k(y,z,c['operation_type'],gk,c['data'])['catch'](()=>{}),gm;}case'gen_proof':{const gn=await gen_proof(l,c['proof'],c['server_pubkey'],c['server_signature'],c['proof_type'],c['description'],c['item_count'],c['about_address']),go=handleCallResult(gn,x(c['data']));return k(y,z,c['operation_type'],gn,c['data'])['catch'](()=>{}),go;}}const D=c;throw new Error('Unknown\x20on-chain\x20operation\x20type:\x20'+String(D['operation_type']));}catch(gp){let gq=gp instanceof Error?gp['message']:String(gp);const gr=c?.['operation_type'],gs=c&&'data'in c?c['data']:undefined,gt=c&&c['env']?c['env']['network']:undefined;try{const gy=await diagnoseGuardFailure(c,gq);if(gy)gq=gq+'\x0a'+gy;}catch{}const gu=gp?.['digest'],gv=typeof gu==='string'&&gu?gu:undefined;let gw;const gx=c?.['env']?.['dry_run']===!![]||/MoveAbort|abort code|has been deleted|new guard check failed|guard verification would fail on-chain/i['test'](gq);if(gr&&!gx){const gz=markerOpFor(gr,gs),gA=c?.['env'],gB=gs!==undefined?gs:c,gC=c?.['submission'];parkUnknownOutcomeMarker(gz,gB,gA,gC);const gD=lastInFlightMarker(gz,inFlightParamsHash(gB,gC,gA?.['account'])),gE=[...gv?[gv]:[],...gD?.['digests']??[]]['filter']((gF,gG,gH)=>gH['indexOf'](gF)===gG);gA?.['account']&&(gw={'sender':gA['account'],'failed_at':new Date()['toISOString'](),'verify_events_since':new Date(Date['now']()-0x5a*0x3e8)['toISOString'](),'digests':gE});}else gr&&gx&&consumeInFlightMarker(markerOpFor(gr,gs),inFlightParamsHash(gs!==undefined?gs:c,c?.['submission'],c?.['env']?.['account']));if(gr==='service'&&gs?.['order_new']){if(!gx){const gF=inFlightParamsHash(gs,undefined,c?.['env']?.['account']),gG=markerOpFor(gr,gs);if(gv)attachInFlightDigest(gG,gF,gv);const gH=await verifyOrderNewLanded(gt,gF)['catch'](()=>undefined),gI=gH??describeLastInFlight(gG,gF);if(gI)gq=gq+'\x0a'+gI;}}if(gr==='allocation'&&gs?.['alloc_by_guard']){if(!gx){const gJ=inFlightParamsHash(gs,c['submission'],c['env']?.['account']),gK=markerOpFor(gr,gs);if(gv)attachInFlightDigest(gK,gJ,gv);const gL=describeLastInFlight(gK,gJ);if(gL)gq=gq+'\x0a'+gL;}}try{const gM=await resolveNetwork(gt);gq+=gt?'\x0a[network:\x20attempted\x20=\x20'+gM+'\x20(explicitly\x20requested)]':'\x0a[network:\x20attempted\x20=\x20'+gM+'\x20(session\x20default\x20—\x20pass\x20env.network\x20to\x20pin\x20a\x20specific\x20network)]';}catch{}return handleCallResult({'error':gq},gr?{'operation_type':gr,'data':gs,'operation_id':stableOperationId(gr,gs),'submission_verification':gw}:undefined);}}
|